help

I'm a new programmer ! I want to run the hello world. after entering the codes in the bloc not I don't know how to save the file. i'm using windows operating system.
thank u for helping.
Ok what exactly is your question? I'm confused. Are you trying to write the "Hello World" program or are you trying to post the code in order for us to find an error?
I want to know which file name I should use for the saving so that it can run.
Last edited on
I'm still confused are you asking what type of il you should save it as? because all C++ source file names should have ".cpp" at the end?

OR

If you're asking what to name the file, that's completely up to you. It doesn't matter to the compiler what you name the file.
exactly what type of il ? firstly I did it with ".c" at the end !
that should have been file. but just right click that file, go to open with notepad, copy and paste it back into your compiler. Then save it with .cpp ..... No big deal.
let have a look on my program to check wether it is correct or not.

#include <stdio.h>
main()
{printf("hello,word\n");}

is it correct ?
well this is alot different than a lot of people would've done it but I don't think that this works.
The only reason that this doesn't work is because on the second line, you forgot the return type. which is usually type "int"

The typical "Hello world application is like this."

1
2
3
4
5
6
#include<iostream>
using namespace std;

int main(){
     cout << "Hello World" << endl;
}
sonlysystem, that is C programming

however if you are writting and C, make sure you include the pause statement to pause your output on screen when it runs.
1
2
3
4
5
6
7
#include <stdio.h>
#include <stdlib.h> // for system("PAUSE");
main()
{
      printf("Hello World!\n");
      system("PAUSE");
}
however if you are writting and C, make sure you include the pause statement to pause your output on screen when it runs.


That issue has nothing to do with C. It is what happens when you run a console program from inside an IDE. It's not a real issue - if you run a console program from something that isn't a console, it's what happens.

system("PAUSE");
This is bad. Firstly, you have to include <cstdlib>. If your compiler does that for you, it's not doing you any favours. Secondly, it's very expensive - http://www.gidnetwork.com/b-61.html . Thirdly, it will only work on a system where calling the OS shell is sensible AND that shell interprets the PAUSE command appropriately. It's very non-portable and it's dangerous. It surrenders your program to some other program entirely, which could be doing absolutely anything. There are many better ways to achieve the same goal.

http://cplusplus.com/forum/beginner/1988/
Last edited on
Topic archived. No new replies allowed.