Go Down

Topic: Convert String to long ? (Read 149 times) previous topic - next topic

Gweno

Hi everybody,

I need help for my school project ?

Is it possible to convert a String to a long ?

I don't understant what I found on Google... :smiley-confuse:

Thanks for help

GolamMostafa

#1
Mar 25, 2019, 02:15 pm Last Edit: Mar 25, 2019, 04:49 pm by GolamMostafa
We will help you if you try to answer the following questions.

1.  What is a character?
2.  What is the ASCII code of the character A?
3.  What is the binary code of the hexadecimal digit A?
4.  What is a string from programming point of view?
5.  What is a String from programming point of view?
6.  What is an array?
7.  What is a NULL-byte?
8.  How many bits make up a byte?
9.  What is an int?
10.  What is an unsigned int?
11.  What is an unsigned long int?
12.  What is an unsigned long?
13.  What is an integer?

groundFungus

#2
Mar 25, 2019, 02:24 pm Last Edit: Mar 25, 2019, 02:24 pm by groundFungus

lastchancename

Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

groundFungus

#4
Mar 25, 2019, 04:53 pm Last Edit: Mar 25, 2019, 04:54 pm by groundFungus
The op said String (capital S or String object).

The strtol() function works with strings (null terminated character arrays or C-strings).

So it depends on which type the OP is actually working with.

OP, FYI, Strings can cause memory fragmentation that causes weird errors if misused (see here).  Null terminated character arrays (strings or C-strings) do not have those problems.


lastchancename

Ya, I was trying to steer OP away from Strings.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

Go Up