All right, here it goes. I'm trying to get an intger from a string. FOr example I don't want "this" to be 4 intgers, I want to get AN intger from "this" Is there any easy way to do this?
Printable View
All right, here it goes. I'm trying to get an intger from a string. FOr example I don't want "this" to be 4 intgers, I want to get AN intger from "this" Is there any easy way to do this?
What do you mean by "this"
Store the 4 characters in an int in some way?
Say
Code:int floogle = 't'<<24 | 'h' << 16 | 'i' << 8 | 's'
int whatevar = (int) 'this' ;
>int whatevar = (int) 'this' ;
And this is supposed to be meaningful, how?
>I'm trying to get an intger from a string.
Be more specific. You can get an integer from a string many different ways, it depends on what you want to do with it.
Hi,
Do you mean something like this?
union aryint ai;Code:union aryint
{
char chrs[4];
int x;
};
ai.chrs[0] = 't';
ai.chrs[1] = 'h';
and so on.
Then
printf("The int is %d",ai.x);
Is this what you want?
Another wild attempt at answering the non-specific question:
http://faq.cprogramming.com/cgi-bin/...&id=1043284385