954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Storing parts of a string to array

Im trying to take input data from a user as a string of number or letters and store each char on a different array, whats the proper syntax fro this?

gdubz
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

you can use this

string letters[5];
float numbers[5];

then ask a question like enter a string and cin >> letters[0]

cout << "type a string? (without spaces) ";
cin >> letters[0];
cout << "type a number. ";
cin >> numbers[0];

Zvjezdan23
Junior Poster
154 posts since Dec 2010
Reputation Points: -3
Solved Threads: 5
 
data from a user as a string of number or letters and store each char on a different array


a loop that will copy the current value of the array depending on its index to another array with the same index

zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
 

i meant to say take in in series of letteres and numbers and storing each individual character on a seperate index of a single array

for example

cin > x;

a9j2 is entered
and the a is stored to array[1] 9 to array[2}]

what what me the syntax for this?

gdubz
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

I don't know. I am not familiar with that. Did you try googling getline(cin,numbers_and_letters) ?? That would be my best guess. but idk how to make the if-else statement to separate that. I'm sorry I'm not that much of a help.

Zvjezdan23
Junior Poster
154 posts since Dec 2010
Reputation Points: -3
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: