can't execute

Pages: 12

1
2
3
4
5
6
7
8
#include<iostream>
#include<conio.h>

int main() {

std::cout << "I am so so so changed ";

} 


 Failed to execute 


Why do i get it?
Last edited on
You simply add return 0 after line 6.
what ide are you using ? did the log print something else ? maybe there's something wrong w/ the project's path ?
thanks.,. i used to use Turbo C++ .. But i used Dev C++ in this program
I can compile it with GCC on Linux if I remove #include<conio.h>, it must be some kind of windows only header. And is not even standard for windows compilers. I recommend not including it.
Last edited on
Try this one one. It works for me -

1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main()
{

cout<<"I am so so so changed "<<endl;

return 0;
}


In your code, you have specified using int main() function that your code will only end when you type any int(or integer) number at end with "return" function. So to end your program, you just have to add return 0; at end of your code.
In your code, you have specified using int main() function that your code will only end when you type any int(or integer) number at end with "return" function. So to end your program, you just have to add return 0; at end of your code.


If the end of main is reached, it as if the user returned 0. One needn't explicitly return 0 from main, although this is not true of other functions which return values. main is a special case.

I would guess the OP gets a more explicit error message than he is supplying.
lol...engr...i guess this is ur 3rd post asking the same question....
ur problem is with ur compiler settings(32bit,64bit)...whatever others are saying about return etc is perfectly correct also but i hope that if u perform this correction still this problem will exist..
stay blessed
thanks it works...

what if i use
1
2
3
4
5
 void main(){


return void;

will it workStarSonic7?

yes..nomijgr

I used to use Turbo C++..now I am using Orwel Dev C++ so it is a new thing to me.. i completed C++ in 3rd semester.. but i got little of it..

:(
@engr
Your school gave you a great disservice in teaching C++ with some non-standard compiler. They should have though GCC because that compiler is cross platform, or at least the Microsoft Visual Studio C++ Compiler. Which uses all standard C++ functions and adds some only windows once.

Also all C++ programs must have an int main( ) or int main( int argc, char** argv ). And even if you had a void function, the point of a void function is that it does not return anything.
Umm. I guess it will :)
@StarSonic7
No it will not work.

1
2
3
4
5
6
#include <iostream>

void main()
{
    return void;
}

GCC output error;

test.cpp:3:11: error: ‘::main’ must return ‘int’
test.cpp: In function ‘int main()’:
test.cpp:5:9: error: expected primary-expression before ‘void’
test.cpp:5:9: error: expected ‘;’ before ‘void’
test.cpp:5:9: error: declaration does not declare anything [-fpermissive]
lol it won't you always have to have int main(){ }
also u cant return void, void functions don't return anything
vaselinko93 oh I hope so.. what is GCC? I used on Windows XP...

GCC is the GNU Compiler Collection (originally the GNU C Compiler), a multi-platform collection of frontends for compilation, and happens to be pretty much the most popular C and C++ compiler around. Using Windows XP, you would use MinGW (Minimalist GNU for Windows), which is a port of GCC to the windows operating system. I would definitely recommend you use it, probably the easiest way to get started is to download an IDE that comes with it (look up Code::Blocks).
ohhhhhhhhh @NT3 which one should I download? minGW or Code::Blocks? O am using Orwel DEV C++ now.. it is new for me.. before that i used Turbo C++ and Turbo C for C programming
You could probably use Orwell DevC++ (from what I've seen, its not as bad as the original), though you could get Code::Blocks instead (I prefer it, but that might just be me, I had a few problems with Orwell DevC++ crashing at inopportune moments). Anyway, Orwell DevC++ actually comes with a form of MinGW (The TDM-GCC build), which is perfectly sufficient for your needs. It also has the added bonus of by default linking statically, which means that you don't need to provide DLL's for your programs. But yes, definitely DO NOT use Turbo C++.
I am using Orwel Dev C++..but the syntaxes are very strange to me.. like std::cout ..I skipped using namespace std; in Turbo. else it shows wrong. but here it should be included or std::cout is used.. which is new to me
but the syntaxes are very strange to me
- that's the unfortunate consequence of starting out with the obsolete Turbo C++. Sadly, it's used in some educational courses, which means as you've discovered, the need to un-learn certain things when eventually encountering standard C++.
Pages: 12