-
char array
ok i have to read in a string of numbers and chars into an array.
i'm a little confused on how i should do this because the string will have single and also double digit numbers. so i can't use an array of chars right?
can i do this using an array of ints?
can i do this using the isdigit funtion?
thanks
Siciliano---
-
if input needs to all be in the same array and input looks like this:
smoothie 1.345 2567 a 14 345
then you need to use a char array as a string and use getline() to read it all in at once. Here's one way:
char dummmy[256];
cout << "enter up to 255 letters, numbers and other chars" << endl;
cin.getline(dummy, 256, '\n');
cout << dummy << endl;
If you elect to do this, then you should read up on getline() and the special issues associated with it's use.
-
you can use an array of chars because a char is nothing but a number which when printed you are asking the compiler to output the character assigned to that number.
-
cool thanks i was thinking of doing a process to the inputted string while it was being inputted, i don't know why i didn't think of doing it this way heheh
I think i need a break from this program lols
thanks :)
Siciliano__