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.

closed strtoint in pascal?

+4 votes
asked Dec 2, 2020 by Faishal Kemal (170 points)
closed Apr 18, 2022 by Admin
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;


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


closed with the note: answered

4 Answers

0 votes
answered Dec 2, 2020 by Peter Minarik (80,300 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 Apr 6, 2021 by root (810 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 Apr 7, 2021 by Peter Minarik (80,300 points)
Good point! I'm glad someone knows their way around  Pascal. :)
0 votes
answered Aug 28, 2021 by abd11a (260 points)

Use val()


function strtoint( s:string ):longint;
  var err:integer; i:longint;

var x:longint;
    x := strtoint('12');

0 votes
answered Apr 16, 2022 by Suren Nanayakkara (140 points)

You need to import the sysutils into your program.

program kelaslabor;
Uses sysutils;
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.