## Pascal

Moderators: None (Apply to moderate this forum)
Number of posts: 14016

This Forum Only

Converting an integer into a string Posted by MadPanda on 22 Nov 2002 at 6:28 AM
i want to convert an integer to a string in turbo pascal, why will these lines of code cause an error, strings can hold numbers cant they?
or am i looking at it from thew wrong angle

I : integer;
S : String;

I:=S

any help would be appriciated from a clueles begginer
Re: Converting an integer into a string Posted by zibadian on 22 Nov 2002 at 7:47 AM
: i want to convert an integer to a string in turbo pascal, why will these lines of code cause an error, strings can hold numbers cant they?
: or am i looking at it from thew wrong angle
:
: I : integer;
: S : String;
:
: I:=S
:
: any help would be appriciated from a clueles begginer
:
Use the Str() function.
Re: Converting an integer into a string Posted by richard_wise25 on 24 Nov 2002 at 11:31 AM
var
i: integer;
s: string;
begin
str(i, s);
write(i);
Re: Converting an integer into a string Posted by viv. on 30 Nov 2002 at 6:43 PM
you can't store a integer variable into a string var.

note that you can store an integer value in a real var. etc

Re: Converting an integer into a string Posted by zibadian on 1 Dec 2002 at 3:51 AM
: you can't store a integer variable into a string var.
:
: note that you can store an integer value in a real var. etc
:
:
You can store an integer in a string, but when you want to perform a calculation with that integer, you need to convert it to an integer. It is possible to store any variable in any other variable, as long as you define the rules to convert the two.
Re: Converting an integer into a string Posted by viv. on 1 Dec 2002 at 11:45 AM
: : you can't store a integer variable into a string var.
: :
: : note that you can store an integer value in a real var. etc
: :
: :
: You can store an integer in a string, but when you want to perform a calculation with that integer, you need to convert it to an integer. It is possible to store any variable in any other variable, as long as you define the rules to convert the two.
:

i tried, it doesnt work , the compiler will tell you type mismatch.

Re: Converting an integer into a string Posted by zibadian on 1 Dec 2002 at 2:41 PM
: : : you can't store a integer variable into a string var.
: : :
: : : note that you can store an integer value in a real var. etc
: : :
: : :
: : You can store an integer in a string, but when you want to perform a calculation with that integer, you need to convert it to an integer. It is possible to store any variable in any other variable, as long as you define the rules to convert the two.
: :
:
: i tried, it doesnt work , the compiler will tell you type mismatch.
:
You need to convert it using Str() or Val(). You cannot directly assign it.

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic