Dev C++ Help

Started by
26 comments, last by owiley 19 years, 5 months ago
I have just compiled the code with the using namespace std;. Its screwed, and so to fix this add << endl; to cout << "hello world"

the code should look like this:
#include <iostream>using namespace std;int main(){cout <<"hello world";system("pause");return 0;}



don't you have a book you can look at??
"All beings came from Chaos" -Romans"Veni, Vidi, Vici"- Julius Caesar
Advertisement
Im at work right now and I will try it as soon as I get off but the program should look like this you say:

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
std::cout <<"hello world"; /*STD would be in this line*/
system("pause");
return 0;
}

Computers are worlds of Exploration?
Compiles fine in my Dev-Cpp, no errors and I get "hello worldPress any key to continue..."(there´s no '\n' or endl there ;)).
You don´t need to add "using namespace std" according to current C++ specs. cout is enough.
Do you have the 4.9.9.0 version of Dev-Cpp?

ch.
You don't have to use using namespace std; if you use std::cout << "Hello world#@!"; and vice versa.

Have a look at the beginners C++ tutorials on GameTutorials.com, they should help you out.
No books as of right now but I have been using online tutorials. I figure if there was talanted people enought to make free great software for people to learn I thought maybe there would be a tutorial out there too.
Computers are worlds of Exploration?
Wow, this is what I need and have been looking for!!!!! Thanks alot Evolutional!!!!
Computers are worlds of Exploration?
a free version of thinking in c++
make sure to scroll down to the bottom to get volume one
-----------------------------------Panic and anxiety Disorder HQ
This code shows only this on my screen: Press any key to continue............

#include <stdlib.h>
#include <iostream>
using namespace std;

int main()

int min=0, max=0, i=0;

cout << "Input your first number to count from: ";

cout << "Input your last number to count to: ";
"
cin >> max;


for(i=min; i <= max; i++)
{
cout << i << endl;
}
system("pause");
return 0;
}

Very weird considering the program skips conditions on the for loop. Now my question is how do I stop it from doing that.
Computers are worlds of Exploration?
First off, you have no opening bracket for your main() function. There are numerous other errors there too. Technically, that shouldn't even compile.

This works fine for me:

/* [GameDevExamples\TestCounter\TestCounter.cpp] *  * Autogenerated with k2_Doc2Code tool. * * Description: *    Simple counting program. */#include <iostream>int main(){	int minValue = 0;	int maxValue = 0;	std::cout << "Enter minimum value and maximum value: " << std::endl;	std::cin >> minValue >> maxValue;	std::cout << "Counting from [" << minValue << "] to [" << maxValue << "]:" << std::endl;	for (int i = minValue; i <= maxValue; i++)	{		std::cout << "Current value: " << i << std::endl;	}	return 0;}


Sample output:
Quote:Enter minimum value and maximum value:
4 13
Counting from [4] to [13]:
Current value: 4
Current value: 5
Current value: 6
Current value: 7
Current value: 8
Current value: 9
Current value: 10
Current value: 11
Current value: 12
Current value: 13
Press any key to continue
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Quote:Original post by C_Programmer0101
This code shows only this on my screen: Press any key to continue............

#include <stdlib.h>
#include <iostream>
using namespace std;

int main()

int min=0, max=0, i=0;

cout << "Input your first number to count from: ";

cout << "Input your last number to count to: ";
"
cin >> max;


for(i=min; i <= max; i++)
{
cout << i << endl;
}
system("pause");
return 0;
}

Very weird considering the program skips conditions on the for loop. Now my question is how do I stop it from doing that.

Is this an exact copy of your code? Because if it is then it shouldn't even compile. Right off hand, you need an opening brace after the int main() and there's a quotation mark sitting all alone on the line before cin >> max;.

Also, while this won't cause an error, you have two couts in a row asking for information, but only one cin to get input. I would rewrite it like so:

#include <stdlib.h>#include <iostream>using namespace std; int main(int argc, char** argc) {int min, max; cout << "Input your first number to count from: ";cin >> min;cout << "Input your last number to count to: ";cin >> max; //Note:  You don't actually need an i variable, you could just use min, since you won't be needing its value againfor(int i = min; i <= max; i++) { cout << i << endl;}system("pause");return 0;}

This topic is closed to new replies.

Advertisement