converting a string to a int value

Aug 28, 2010 at 2:45pm
How do i convert a string of words into a int value?

What is the code for it?
Aug 28, 2010 at 2:55pm
Did you tried to use the search feature of this site?
I guess not... Try entering the exact title of this topic, you will find what you want.
Aug 28, 2010 at 2:55pm
A string of words like "seven hundred twenty two" ?
Aug 28, 2010 at 2:58pm
If you meant that, than I'm sorry, you will not find it there. But make your question more obvious next time.
Last edited on Aug 28, 2010 at 2:58pm
Aug 28, 2010 at 3:47pm
i tried searching to no avail?

my question is for example a string "This is a boy" and to convert this into a integer value. how do i do it?
Aug 28, 2010 at 3:50pm
That doesn't make sense...
Do you want a hashing function?
Last edited on Aug 28, 2010 at 3:50pm
Aug 28, 2010 at 3:52pm
It doesn't have an integer value to convert to. What it DOES have is a string of characters that can be represented as both a number and a letter. Maybe you wanted this?
MyString[x] Where x is the character you want to get.
Aug 28, 2010 at 4:05pm
atoi(char *)
Aug 28, 2010 at 4:45pm
well you can convert it into an integer with the help of the function strlen() ,witch is found in the string.h library.the function returns the number of characters that the string is composed of.for example "hello world" the function will return the value 11. any character is evaluated,even space.
that is all y can think of.hope it helps.
Aug 28, 2010 at 4:50pm
this is an example of the source code and the parameters of the function.
1
2
3
char Text1[20]={"Hello World"};
int TextSize=strlen(Text1);
printf("%d\n",TextSize);
Last edited on Aug 28, 2010 at 4:53pm
Topic archived. No new replies allowed.