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?
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?
#define punkCow
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'
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
>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.
My best code is written with the delete key.
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?
Pappy
You learn something new everyday.
Another wild attempt at answering the non-specific question:
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]