Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

In C, how to I convert a string, like "0xffffff0", into an integer with the value 0xfffffff0

OpenStudy (anonymous):

in other words, how do I convert a string that represents a hex number into an integer containing the value of that number?

OpenStudy (anonymous):

you want algorhitm? or just use built in function or library?

OpenStudy (anonymous):

convert string to char, just ffffff, i think you know how to do it, but I don't then main //blablab idk what to write here { int decimal =0 for (int index = 0; index < 6; index++) { //convert char to integer power = 5; int integer = charToInt(char[index]); decimal += pow(integer, power); power--; } printf("%d", decimal); //idk how to print } // idk how to write function in C but it takes character returns string function int charToInt(char character) { switch(character): case '0' : return 0; case '1' : return 1; ...//repeat same case 'a' : return 10 case 'b' : return 11 case 'c' : return 12 case 'd' : return 13 case 'e' : return 14 case 'f' : return 15 default : return 0 }

OpenStudy (anonymous):

I just want to replace scanf with something else in this program: http://ideone.com/iK83i

OpenStudy (anonymous):

sorry but i don't understand that code with weird c syntax :D

OpenStudy (farmdawgnation):

Just out of pure curiosity, why are you writing a program to read arbitrary blocks of memory. That just sounds like a potion for trouble! Ha! That said, you could replace it with gets - which will return a string from the standard in. There are lots of other options as well, I suppose. What do you need to do that scanf won't?

OpenStudy (farmdawgnation):

Gah, 10 points for forgetting a question mark at the end of my first sentence.

OpenStudy (anonymous):

where's edit button? and also he does a lot weird stuff with weird c language :D

OpenStudy (farmdawgnation):

We haven't implemented an edit button yet, unfortunately. I'm going to suggest it to shadowfiend when I think to. And it's not so much weird stuff as it is interesting. He's running into a lot of interesting problems and concepts.

OpenStudy (anonymous):

i think edit button was suggested bazilion times :P

OpenStudy (shadowfiend):

It has, and we've explained the rationale for it being extremely low priority an equally large number of times.

OpenStudy (shadowfiend):

agdgdgdgwngo, have a look at sscanf. It does the same thing as scanf, only it reads from a string instead of standard input.

OpenStudy (anonymous):

what a scanf does ?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!