Welcome to Gaia! ::


Well, I have this c++ project to do, but I'm stuck on one thing. I need to convert a string into an array of characters. So far, I'm stuck on what kind of options I have. I'm using the library string.h and I want some way to read the string character by character and store the characters in an array. It can be either a string or a char as the datatype. Thanks.
C++, eh?

There should be a function/method that'll let you read a character one-by-one..say something like charAt([index-integer]) of Java fame.

It should be simple to set up an array the length of your string then run a for loop to do the actual reading..

Say: for(int i = 0; i <= String.length; i++)
charArr = String.charAt(i);

I don't remember the REAL name for C++'s charAt-like function..shouldn't take that much searching, though (Sorry, I took C++ for 2/3 of a year then was migrated to Java..they're really alike in lots of ways, though)
use an array of char and affect the first letter of ur string to the array and loop till the end of the string wich mean its length i hope this what u lookin for

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum