0

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?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Zvjezdan23
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];

0

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

Edited by zeroliken: n/a

0

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?

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.