variable.
Lets say this is the content of a text file.
///////////////////*******content
1A
1C
1F
//////////////////////////end of file
How do I assign it to an array of ints.
variable.
Lets say this is the content of a text file.
///////////////////*******content
1A
1C
1F
//////////////////////////end of file
How do I assign it to an array of ints.
Here's a big hint:
ggCode:#include <stdio.h> int main() { char str[] = "0A"; int n = 0; sscanf(str, "%x", &n); printf ("%d\n", n); return 0; }//main
Last edited by Codeplug; 05-12-2004 at 10:02 PM.
Do you know how to use an array? Do you know how to open a file? Do you know how to read from a file? These are all things you need to know. For starters, consider reading up on fopen, fclose, fgetc, fgets, fscanf.
As per the standards of the forum, post your attempt, and we'll offer assistance when you're stuck. Be sure to note any errors, or what specificly you're having trouble doing. But then you already know that, because you surely have read the Announcement regarding it.
Quzah.
Hope is the first step on the road to disappointment.
Yes, my question looks like a homework question. I actually did not need help anymore. I got what I needed from a reference site after I posted the first one. fscanf and %x was what I needed.
hmmm, I knew about fscanf..but what is sscanf...