OPEN / INPUT?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Nah, I think that is set, I found out QB can read 32767 chars to a string$,. it read myfirst HTML site I put togetter.. I might add to its reading ability on tags if I find some that will combat with QBs limits.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Hey Hey, do you know why that that's the limit?

Well do you know the limit of an array in QB?

It's 32767 if I'm not mistaken....

Now do you know that a String is just an array of chars?

Makes sense doesn't it.... :D

In C++ the is a var called char, it's like int, or double, or long, or string, etc.

a char is like a string but only 1 value....

It's very easy to convert chars to ints, because when you cast a char to an int you get the ASCII value of that char in the int.

So

char i='9';
cout<<int(i)<<endl;

would output

57

and

int i=57;
cout<<char(i)<<endl;

would output

9

Notice the ' ', you have to do that for a char like you do " " for a string.
Now C++ can't directly cast a string to an int so what so you do? You make each one a char that you want to....

Now in QB this is easy you have the val() and the str$()

But in c++ its not that easy

but to make a certain part of a string in C++ an int is easy cause you don't need to deal with substr (like mid$ in QB):
Since a String is an array of chars:

string A="12334"
cout<<int(A[1])<<endl;

Guess what that would output?

A[1] is a char so

it would output ascii(2) what ever that is

wait a minute you said A[1] = 2?
isn't A[1] = 1? cause its in the first slot?
NO it starts at 0! then the second pos is 1, very confusing expesially for the .length() method and converting...heh

Oh well I guess I went off topic again...heh
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:shock: Umm, eh, heh heh, what did you say? :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

:shock: What you didn't hear me or somtin? Ok here I go again I said:
Mitth'raw'nuruodo wrote:Hey Hey, do you know why that that's the limit?

Well do you know the limit of an array in QB?

It's 32767 if I'm not mistaken....

Now do you know that a String is just an array of chars?

Makes sense doesn't it.... :D........................
...........................................................
..........................................................
..............................................................
Was that what you wanted?
Ummm I would have to be the stupidest person in the world if I thought thats what you ment....lol

Lets see simpl:
- char is a var thats a string with 1 value
- string is a var thats an array of chars
- In C++ you can get a char var by getting that element in a string array that corresponds to the position in the string, which starts at zero.
- EXAMPLE:

Code: Select all

String Hello = "from";
char A = Hello[3];
//since 3 is the 4th position (starts at 0) in the string the output to A is 'm'.
cout<<A<<endl;       //that's PRINT in QB
OUTPUT:
m

Is that good enough now or were you joking? he he. :D
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:lol: , I'm using char as short for CHARacters,. loads of QBers do it I think.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

That's what char stands for 1 character of a string....
and therefore a string is an array of characters, or chars. :wink:
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:lol: Ha ha, okay you win,. :roll: :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Post Reply