Dev C++ help strings?

Started by
5 comments, last by NibbIe 16 years, 3 months ago
Hi I am a very new c++ programmer (I started yesterday) and I have found that dev c++ is an alright program for me I was mucking around trying to get a better understanding of C++ and I came across a few tutorials on using strings I have tried to put strings into a test program but it doesn't seem to work and I have no idea how to make it work could sombody please help me? the error is: `class string' used where a `int' was expected the code is: #include <string> #include <iostream> using namespace std; int main() { int number; int number2=2; int determine; string result; string result2; result="hi"; result2="bye"; cout << "Hello World!" << endl; cout << "Press a 1 or a 3 to continue..." << endl; cin>>number; determine=(number>number2)? result:result2; cout << determine; cout <<"\n"; system ("PAUSE"); return 0; }
Advertisement
determine should be a std::string because this expression determine=(number>number2)? result:result2 returns a string(result or result2).
.
You have int determine. Perhaps you meant string determine?

In any future posts, please observe the following:

- Surround code with CODE tags. This preserves indentation and formatting, allowing us to read your code. You'll get more responses if you do so.
- Do not use the words "doesn't work". It's great in casual conversation, but in technical posts, is a completely meaningless phrase. You need to describe precisely what your observations were, and what you actually expected to see. Don't diagnose the problem, just your observations and expectations. We'll figure out the rest.

Cprogramming.com and cplusplus.com are good online tutorials. Honestly, I would recommend a good book. C++ Primer by Lippman and Accelerated C++ by Koenig accurately depict Modern C++ so I recommend either (or both) of those.

Feel free to ask any other questions you have.
thankyou very much
that solves my problem and gives me more understanding of C++
I sometimes overlook simple things like that when i am programming.
once again thankyou.
[snip]
int determine;
[snip]
determine=(number>number2)? result:result2;
[snip]

come on, you can figure this out ;)

EDIT: blah, too late
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
I wouldn't recommend Dev-C++ because it is not maintained anymore. However, I would recommend Visual C++ 2008 Express because it is a very powerful IDE that is free! Also, if your code is more than 10 lines, I would recommend the [ source ] (without the spaces) tags instead of the tags.<br><br>Good Luck!<br><br>Edit: Fixed error in link!
Yea, you can use the express edition of visual studio that's available for free and its a lot better than devcpp. click

EDIT: Never mind beaten [rolleyes]

This topic is closed to new replies.

Advertisement