Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help me with my code, I'm trying to get a specific integer from my .txt File
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
superben20




PostPosted: Wed Jan 06, 2016 10:12 pm   Post subject: Help me with my code, I'm trying to get a specific integer from my .txt File

What is it you are trying to achieve?
I want to be able to change 1 specific integer from a .txt File that only has specific integers on a different line.


What is the problem you are having?
I kept on having problems saying that there is an illegal character in the string, but I want an integer, not a string. I want 1 specific integer changed, not all of them.


Describe what you have tried to solve this problem
Looking the Web, and trying everything that was posted on the Compsci website, none of them worked well enough


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var badges, Badge : int
var temp : array 1 .. 3 of int
    open : badges, "Badges.txt", get
    get : badges, temp(1)
    close : badges
    put : temp(1)



Please specify what version of Turing you are using
Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Jeffmagma




PostPosted: Thu Jan 07, 2016 12:33 pm   Post subject: Re: Help me with my code, I'm trying to get a specific integer from my .txt File

Get them as strings, then use strintok to check if its the number you want
superben20




PostPosted: Thu Jan 07, 2016 1:58 pm   Post subject: Re: Help me with my code, I'm trying to get a specific integer from my .txt File

Ok, I tryed that, and it didn't work, it still says that there is an illegal character in the string:

var temp : array 1 .. 3 of int
var dummy : string
open : badges, "Badges.txt", get
for i : 1 .. 3
get : badges, dummy
if strintok(dummy) then
temp(i) := dummy
close : badges
open : badges, "Badges.txt", put
put : badges, temp(i)
end if
end for

This is the code that I have, I know that it doesn't work because the error of the illegal character in the string.
Insectoid




PostPosted: Thu Jan 07, 2016 2:10 pm   Post subject: RE:Help me with my code, I\'m trying to get a specific integer from my .txt File

strintok() only checks if the string can be converted to an integer. strint() does the actual conversion.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: