Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

strtoint in pascal?

+3 votes
asked Dec 2, 2020 by Faishal Kemal (150 points)
my teacher said that i need to use strtoint in my pascal code

but it said that the identifier not found 'strtoint'

this is my code

program kelaslabor;

var
    sBufer:string[5];
    d,m:integer;

begin
    writeln('write date on DD:MM');
    readln(sBufer);
    writeln(sBufer);
    
    {d:=strtoint(sBufer[1])*10 + strtoint(sBufer[2]);
    m:=strtoint(sBufer[4])*10 + strtoint(sBufer[5]);
    writeln(d,' ',m);}

    d:=strtoint(Copy(sBufer,1,2));
    m:=strtoint(Copy(sBufer,4,2));
    writeln(d,'~',m);

end.

2 Answers

0 votes
answered Dec 2, 2020 by Peter Minarik (22,320 points)
Last time I wrote something in Pascal was about 25 years ago, rofl.

Did you miss an include?

Maybe this one helps: https://www.freepascal.org/docs-html/rtl/sysutils/strtoint.html
+1 vote
answered 5 days ago by root (620 points)

strToInt is not standardized, but readStr is (in ISO 10206 “Extended Pascal”). You can use readStr pretty much like a regular read/readLn:

readStr('123456', i);

Where i is the name of an integer variable. The string could be of course the name of a (string) variable as well, it doesn’t need to be a constant string literal.

commented 4 days ago by Peter Minarik (22,320 points)
Good point! I'm glad someone knows their way around  Pascal. :)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...