Loading
submit to reddit
May 22, 2013, 08:11:45 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Help needed  (Read 968 times)
Ghorian
Newbie
*
Posts: 2


« on: March 27, 2010, 06:34:38 PM »

Hello, i started to learn c++. I'm very basic program from what i have learned.
The problem is that i have few errors with the code so i hope someone could fix that.
Code:
#include <iostream>
using namespace std;
int main() {
char Pasirinkimas;
int R;
int Atsakymas;
int Kampas;
cout << "Sia programele galime apskaicioti skritulio plota,perimetra,ispjovos plota." << endl;
cout << "Pasirinkite ka skaiciosite" << endl;
cout << "Jai skaiciosite skritolio perimetra rasykite SP, plota SS, ispjovos plota IP" << endl;
cin >> Pasirinkimas;
if(("SP" || "SS" || "IP") != Pasirinkimas) { /* checing if Pasirinkimas is correct */
cout << "Pasirinkite viena is varijantu: SP, SS, IP" << endl;
} else {
cout << "Gerai, parasykite spindulio ilgi" << endl;
cin >> R;
if(Pasirinkimas == "SP") { /* checing which one was choosen */
Atsakymas = 2*R;
cout << "Atsakymas yra " << Atsakymas << "pi" << endl;
}
if(Pasirinkimas == "SS") { /* checing which one was choosen */
Atsakymas = R*R;
cout << "Atsakymas yra " << Atsakymas << "pi" << endl;
}
if(Pasirinkimas == "IP") { /* checing which one was choosen */
cout << "Parasykite kamo dydi" << endl;
cin >> Kampas;
if((Kampas > 360) | (Kampas < 0)) {
cout << "Pasirinkite taisinga kampa! (0-360)" << endl;
}
Atsakymas = (R*R)/360/Kampas;
cout << "Atsakymas yra " << Atsakymas << "pi" << endl;
}
}
return 1;
}
Errors:
Code:
------ Build started: Project: Console lessons, Configuration: Debug Win32 ------
Compiling...
pamoka2.cpp
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(17) : error C2446: '==' : no conversion from 'const char *' to 'int'
        There is no context in which this conversion is possible
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(17) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(21) : error C2446: '==' : no conversion from 'const char *' to 'int'
        There is no context in which this conversion is possible
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(21) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(25) : error C2446: '==' : no conversion from 'const char *' to 'int'
        There is no context in which this conversion is possible
c:\users\rasa\documents\visual studio 2008\projects\console lessons\console lessons\pamoka2.cpp(25) : error C2040: '==' : 'int' differs in levels of indirection from 'const char [3]'
Build log was saved at "file://c:\Users\Rasa\Documents\Visual Studio 2008\Projects\Console lessons\Console lessons\Debug\BuildLog.htm"
Console lessons - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #1 on: March 27, 2010, 07:04:15 PM »

The problems that you are seeing are related to your strings. Take a look at this and it should clear things up for you.  Smiley

http://xoax.net/comp/cpp/console/Lesson44.php

Mike
Logged
Ghorian
Newbie
*
Posts: 2


« Reply #2 on: March 28, 2010, 03:30:51 PM »

I have another problem. I thin serious one when i start "Hello World" program it just executes and ends so i can't really see the results.
Code:
#include <iostream>


int main() {
std::cout << "Hello World" << std::endl;
return 0;
}

Code:
'Lesson1.exe': Loaded 'C:\Users\Rasa\Documents\Visual Studio 2008\Projects\Lesson1\Debug\Lesson1.exe', Symbols loaded.
'Lesson1.exe': Loaded 'C:\Windows\System32\ntdll.dll'
'Lesson1.exe': Loaded 'C:\Windows\System32\kernel32.dll'
'Lesson1.exe': Loaded 'C:\Windows\System32\KernelBase.dll'
'Lesson1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll'
'Lesson1.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll'
The program '[5640] Lesson1.exe: Native' has exited with code 0 (0x0).
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #3 on: March 28, 2010, 10:07:17 PM »

You'll want to watch the video a little more carefully. Wink  You should just select "Start Without Debugging" when compiling in the IDE. Otherwise, you can add the lines of code that we used in our lesson on creating an executable.

http://xoax.net/comp/cpp/visualcpp/CreateExe.php

When you create an executable (an .exe file), you will need to add some sort of code to stop the execution as we showed there.

Mike
« Last Edit: March 28, 2010, 11:37:16 PM by Michael Hall » Logged
Gate99
Newbie
*
Posts: 5


« Reply #4 on: April 08, 2010, 02:36:35 PM »

i made this program for kicks and giggles and it didn't work so i tried to make another one and it also did not work giving me an error that there is some sort of virus detected if i were to open it
Code:
#include <iostream>

int main () {
using namespace std;
cout << "why wont this work?" << endl;
}
the error is...
Code:
1>LINK : fatal error LNK1104: cannot open file 'C:\Users\Gate99\Documents\Visual Studio 2008\Projects\HopethisWorkd\Debug\HopethisWorkd.exe'

and if it helps whatsoever it was some sort of hacking software that was detected. it would be great to start programming again ^^
Logged
Gate99
Newbie
*
Posts: 5


« Reply #5 on: April 08, 2010, 05:02:21 PM »

i think i'm losing my grip on reality...this stupid error is driving me nuts
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #6 on: April 08, 2010, 10:12:05 PM »

You might try downloading our lesson 1 project. Try compiling that and see if it works. If so, then you probably just have something set up incorrectly in the project.

Mike
Logged
Gate99
Newbie
*
Posts: 5


« Reply #7 on: April 09, 2010, 10:21:25 AM »

so...would you have any idea what the setup error would be?
also the lesson did not work
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #8 on: April 09, 2010, 11:00:27 AM »

If that project doesn't work then it must be something unrelated to the compiler. You mentioned that you had a virus? You may want to get that cleaned up first.

Mike
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!