Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
string input into an array
Name: Rich Date: September 6, 2003 at 20:29:54 Pacific OS: 2000 CPU/Ram: C++
Comment:
I'm trying to input a string (123213) and put it into a single dimension array. I'm declaring the array to size 20 which should be big enough fo anything I will need. Anything that you guys can say on this will b appresiated. Thanks.
Name: Chi Happens Date: September 6, 2003 at 20:36:02 Pacific
Reply:
How do you want to do this? char or _basicstring?
if you use char it will already be in an array:
char theWords[20];
Chi Happens
0
Response Number 2
Name: Rich Date: September 6, 2003 at 20:42:19 Pacific
Reply:
I'm wanting to use a string of ints.
0
Response Number 3
Name: Chi Happens Date: September 6, 2003 at 21:16:19 Pacific
Reply:
ok, so char theIntegers[20];
am i missing something?
0
Response Number 4
Name: Rich Date: September 6, 2003 at 21:25:35 Pacific
Reply:
I'm trying not to use a char, i'd rather use an int. I am going to have to do some operations with the numbers. I have tried to load it in as a char and do an atoi command to change it into an int, but it gives me the ASCII value of the number instead of the number (ie. '3' = 51). Is there a way to convert the ASCII back to its original value? Thanks
0
Response Number 5
Name: Chi Happens Date: September 6, 2003 at 21:28:01 Pacific
Reply:
wtf!!!
man, this forum is pissing me off tonight. it keeps jumping back and forth. grrr (I HATE THE JAVASCRIPT ADS!!!!)
Anyhow, try this:
char *str = "12345.67"; n = atoi(str); cout n;
Chi Happens
0
Response Number 6
Name: Rich Date: September 6, 2003 at 22:02:16 Pacific
Reply:
Thats getting me in the right direction (I think). Thanks for your help.
0
Response Number 7
Name: Chi Happens Date: September 6, 2003 at 22:05:01 Pacific
Reply:
this works correctly in vc++ as well as borland c++ (atoi worked right in borland but not in vc++...thanks bill)
Summary: How do I open a file and read data into an array i have a file named wordfind.in this is what my file looks like below. I am attempting to read in the information in the fist paragraph into a 2 demin...
Summary: I just started learning Perl, and i was hoping someone could tell me how to: I have read a file into an array, and sorted it. I want to read line1, then compare it with line2. If match, create ErrorLo...
Summary: I'm trying to write command line input into an array. I understand I need to plug in a loop somewhere to do that but I'm not sure where. I'm new to the langusge. Could anybody advise me on this one? H...