Computer Science Canada Array to string |
Author: | supaphreek [ Wed Jun 02, 2010 11:47 am ] | ||
Post subject: | Array to string | ||
What is it you are trying to achieve? Im trying to use getchar and convert it to a string What is the problem you are having? idk how Describe what you have tried to solve this problem Tried the code below... Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | chrisbrown [ Wed Jun 02, 2010 12:14 pm ] | ||
Post subject: | RE:Array to string | ||
Although you can't "put" an array, you can use a for loop to output each character sequentially, or you can append each character to a string:
|
Author: | supaphreek [ Wed Jun 02, 2010 1:44 pm ] |
Post subject: | RE:Array to string |
Well, im trying to make it as a username... so i need the array to be 1 word in a string. how would i do that? Thx alot tho, i relle appreciate ur help! |
Author: | chrisbrown [ Wed Jun 02, 2010 1:53 pm ] |
Post subject: | Re: RE:Array to string |
supaphreek @ Wed Jun 02, 2010 1:44 pm wrote: i need the array to be 1 word in a string.
I'm not sure what you mean... do you want each element in the array to contain one character? Or each element to contain one username? |
Author: | supaphreek [ Wed Jun 02, 2010 2:05 pm ] |
Post subject: | RE:Array to string |
well, i need to be able to put everything in the array into 1 string.... |
Author: | chrisbrown [ Wed Jun 02, 2010 2:51 pm ] |
Post subject: | RE:Array to string |
Ah ok. Unless it's a requirement, you dont need the array at all, you can just append to a string using the technique in the code i provided. If it is required, my example will still help. After all characters have been read into the array, append each character to a string using a for loop. Again, if required: Turing will make the conversion for you but you should change c to an array of char instead of string for clarity's sake. |