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?

Recommended Answers

All 4 Replies

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

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

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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.