Computer Science Canada Some String to Integer Issues |
Author: | B-Man 31 [ Thu Sep 10, 2009 5:22 pm ] | ||
Post subject: | Some String to Integer Issues | ||
hey, im reading some numbers form a text file and i cant seem to convert them into string, this is what i have. any help would be awesome! Thanks
|
Author: | andrew. [ Thu Sep 10, 2009 5:30 pm ] |
Post subject: | RE:Some String to Integer Issues |
Try using strintok (brick_x_1) to see if it can be turned into an int. I think that you are reading a space or a non-integer. |
Author: | B-Man 31 [ Thu Sep 10, 2009 6:11 pm ] |
Post subject: | RE:Some String to Integer Issues |
I figured it out why its not working, its because the limit i set after the string does not seem to work so it reads more. But now i need to figure out why the read function doesnt use the limit set by the string variable. can anyone help explain this? |
Author: | BigBear [ Thu Sep 10, 2009 6:40 pm ] |
Post subject: | RE:Some String to Integer Issues |
It doesn't matter what you put them into the test file when you open it to get you can simply get as strings |
Author: | B-Man 31 [ Thu Sep 10, 2009 6:55 pm ] |
Post subject: | Re: Some String to Integer Issues |
i know, ive gotten them as strings, i now need to get it to an integer, but the variable, even though it is limited string of 3 characters, still has more than 3 characters including spaces which i cant seem to explain. |
Author: | andrew. [ Thu Sep 10, 2009 8:16 pm ] |
Post subject: | RE:Some String to Integer Issues |
Why don't you just read everything into one big string and then split it into multiple strings after? |
Author: | DemonWasp [ Thu Sep 10, 2009 11:21 pm ] | ||
Post subject: | RE:Some String to Integer Issues | ||
If your string(3) types have more than 3 characters in them, then it's probably a Turing bug. Try using:
to limit input to 3 bytes == 3 characters. |