Tick C++ and Make Default language both.
Then the Default Compiler would be C++.
Ask Neo About C. He will tell the deference of C and C++.
As I remember Neo said that When we Write codes without Classes it would be a C Program.
And As I remember When we Add Header files.
we add
#include<iostream>
in C++
But In C We add
#include<iostream.h>
I might be wrong because I've seen some C++ codes with #include<iostream.h>
For Clear Guide ask Neo. He Knows Better Than Me about those . I will tell you things that I know I am not an
Expert of the Subject.
Thanks
How to start C Programing with Dev C++
Re: How to start C Programing with Dev C++
iostream.h is a C++ header file. We don;t have that in C. In C we use, stdio.h#include<iostream>
in C++
But In C We add
#include<iostream.h>
No difference in using with .h and without .h in C++. In C, we always need to use .hI might be wrong because I've seen some C++ codes with #include<iostream.h>
One other interesting point is about using <> and "" for include files.
If the path is defined to the compiler already (path is known to compiler), you can use <>. But if the path is not known, then you need to mention the exact path which should go within "".
Re: How to start C Programing with Dev C++
Thanks NIPUNA & NEO.I read your posts.Now I am trying to make that HELLO WORLD in DEV C++.I will post my first program progress soon.
Re: How to start C Programing with Dev C++
Hi friends.
I start my first programm in C++.
This is it.But I have a problem.
I compiled it.Its says DONE.
How can I run my code.When I do EXECUTE>RUN
Nothing happens.Just one dialog box came & wanish.
I start my first programm in C++.
This is it.But I have a problem.
Code: Select all
//first testing programm in C++ by G-sparkz
#include<iostream>
using namespace std;
int main()
{
cout<<"I am learning C++!";
return 0;
}
How can I run my code.When I do EXECUTE>RUN
Nothing happens.Just one dialog box came & wanish.
Re: How to start C Programing with Dev C++
That's Because your Program doesn't make for that. I mean it's only work is Print the Word you add and then automatically exit.
It happened to me too. I asked Neo He gave me the solution it is.
add
Before
or you can add
But if you add this one you Program will print this at the end of the program
But the Best thing i say to add is
It happened to me too. I asked Neo He gave me the solution it is.
add
Code: Select all
cin.get();
Code: Select all
return 0;
Code: Select all
system("pause");
Code: Select all
Press any key to continue
Code: Select all
cin.get();
Re: How to start C Programing with Dev C++
I understand the problem. There is nothing holding the output window to stay visible.
You can do two things.
You can do two things.
- Easy way is, execute (Usually Ctrl+F5) the application (Not Debug which is initiated with F5 normally). In Visual C++ we have the following icons. Or else you can open a command window yourself and run the exe file that was compiled.
- Cool way is to let the program wait for a user input. So the screen will hold until you enter something.
You can use following code.Code: Select all
//first testing programm in C++ by G-sparkz #include<iostream> using namespace std; int main() { int i; cout<<"I am learning C++!"; cin >> i; // wait until a number is entered from keyboard return 0; }
Re: How to start C Programing with Dev C++
Wow.Cool,It works.I am loving C more & more.It feels good.
Re: How to start C Programing with Dev C++
I wrote my second program in C.
here it is.
1.I wanna know hot to brake a line in the program.?
2.what is the different between cin.get(); & system("pause");
3.please explain the code cin >> i;
here it is.
Code: Select all
//my second testing programm in C++
#include<iostream>
using namespace std;
int main()
{
cout<<"I am learing C++ ";
cout<<"going to test second programm";
cin.get();
return 0;
}
2.what is the different between cin.get(); & system("pause");
3.please explain the code cin >> i;
Re: How to start C Programing with Dev C++
There are two ways to do this.1.I wanna know hot to brake a line in the program.?
- cout << "Text on first line" << endl << "Text on second line";
- cout << "Text on first line \nText on second line";
cin.get() waits until you enter something using keyboard and press enter so it can get the input back to program.2.what is the different between cin.get(); & system("pause");
"pause" only wait until you press any key. Try to open the command prompt and enter pause to see what it is. system("pause"); calls the same DOS thing.
As said before, cin gets an input from keyboard. Here it get the input (which should be a number) to variable i.3.please explain the code cin >> i;
If you print it using following command after cin, you will understand that.
Code: Select all
count << "I entered " << i << " from keyboard.";
Re: How to start C Programing with Dev C++
Thanks For the help NEO.
This is my newest code.
This is my newest code.
Code: Select all
//my third testing programm in C++
#include<iostream>
using namespace std;
int main()
{
int a,b;
a=10;
b=20;
cout<<"I am learing C++ "
<<endl<<"going to test third programm"
<<endl<<"my first variable test "
<<endl<<"my variables are a & b "<<endl;
cout<<"this is my variable [a] = "<<a<<endl;
cout<<"this is my varianle [b] = "<<b<<endl;
cout<<"I nam going to add my variables"<<endl;
cout<<"[a] + [b] = "<<a+b<<endl;
system("pause");
return 0;
}