Computer Science Canada Removing characters from a file |
Author: | SwAnK [ Wed Feb 15, 2006 11:58 pm ] | ||
Post subject: | Removing characters from a file | ||
hello, what im trying to do is import a file i made with a bunch of words and numbers and commas, and then remove all the commas just leaving the numbers and words. When it does run it comes up with the error "string coerced to char is not length 1." heres the code, could anyone help me out? thanx.
|
Author: | Cervantes [ Thu Feb 16, 2006 8:03 am ] |
Post subject: | |
You're doing a lot of things wrong, here.
Check out the Turing Walkthrough to get links to tutorials on file input/output and string manipulation. |
Author: | Clayton [ Thu Feb 16, 2006 9:19 am ] | ||||
Post subject: | |||||
thats some uh, innovative code you've got there, if you want to find all commas and remove them then make an array with the upper bounds equal to the length of your information, then, make a for loop with the upper bounds being the upper bounds of your array. then code something like this
so what we've done here is created a loop to find all commas and replace them with spaces if you're wondering how this all got into an array it would look something like this
this is taking the string data (fileData) and taking it apart character by character and putting it into stringArray and then you would go into your loop to get rid of commas hope this helps and you really should go to the Turing Walkthrough |
Author: | MysticVegeta [ Thu Feb 16, 2006 11:11 am ] |
Post subject: | |
Why not just search around for a module called String.Replace that I posted... could replace any char with any. |