943,844 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1023
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 7th, 2009
0

Re: system("CD"). Help please :(

Reputation Points: 11
Solved Threads: 6
Junior Poster
jen140 is offline Offline
116 posts
since Jan 2009
Aug 7th, 2009
0

Re: system("CD"). Help please :(

Click to Expand / Collapse  Quote originally posted by jen140 ...
Use strcat(), it is described at http://www.cplusplus.com/reference/c...string/strcat/

I apologise profusely, but i am a newby at programming.

Does that also allow the user to input values with spaces in them? The example given is only a string that has been given a value by the program.

And if so, how?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
licktress is offline Offline
12 posts
since Aug 2009
Aug 7th, 2009
0

Re: system("CD"). Help please :(

The function i talked about is only used to work with strings that you already have, so if you need to mannualy add the space or other content to the given string you can use that function
If i'm not mistaken the user can introduce the string with space without any need to use other functions.
Reputation Points: 11
Solved Threads: 6
Junior Poster
jen140 is offline Offline
116 posts
since Jan 2009
Aug 7th, 2009
0

Re: system("CD"). Help please :(

You don't need to use strcat()... Please don't suggest using the C string library to manipulate C++ strings.

AD already addressed your question. You should be using getline() to get user input:
C++ Syntax (Toggle Plain Text)
  1. string dirpath;
  2. getline( cin, dirpath ); // gets everything, including spaces
Hope this helps.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Aug 7th, 2009
0

Re: system("CD"). Help please :(

Click to Expand / Collapse  Quote originally posted by licktress ...
Okay, it works now, however, if the string has any spaces in it, it doesn't work.

Does anyone know how to add spaces to a string variable?

Thanks for all the help
You could have saved yourself a lot of time had you bothered to read the post I made over 10 hours ago
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,951 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Define abstart overridable method
Next Thread in C++ Forum Timeline: exercise on recursion...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC