Sign in to follow this  

Dev C++ help strings?

This topic is 3633 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 [ code ] tags.

Good Luck!

Edit: Fixed error in link!

Share this post


Link to post
Share on other sites

This topic is 3633 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this