Originally Posted by
Salem
Code:
int value;
while ( fscanf( archivo, "%d", &value) == 1 ) {
if ( value >= 100 && value <= 999 ) {
int size = value % 10;
} else {
int x = value / 10;
int y = value % 10;
}
}
But you haven't said what happens when any size of coordinate is greater than 10.
I really appreciated your help ! (for your question what happened when any size of ..greater than 10 , lets assume it wouldn't happen -an assumption-.
I appreciate once again your code, but checking your code, I have my own code and I need to know what's the problem:
here's my code:
Code:
int main() {
int i, j, F, D, size, num, row1, coL1;
FILE *filep;
double *ptr = NULL;
double x;
if((filep==fopen("NAME.txt", "r")) == NULL) {
printf("\nFailed to open File.\n");
return -1;
}
while (!feof(filep)) {
if (fscanf(filep, "%u", &num) == 1) {
printf("%d\n", num);
}
if (fscanf(filep, "%u%u%u", &size, &F, &D) == 3) {
printf("%d%d%d\n", size, F, D);
if (fscanf(filep, "%u%u", &row1, &coL1) == 2) {
printf("%d%d\n", row1, coL1);
}
}
}
}
the input:
in NAME.TXT is:
Code:
100
3 1 3
2 3
1 2
2 2
3 2
3 2 0
1 3
2 3
3 3 3
1 3
2 3
the output I got
Code:
100
313
23
1
222
32
3
201
32
3
333
13
2
the output isn't the same as the input, its values the same, but it's not organized .. any clue how to output the same output as the input?
I want to print what's found on NAME.txt on my screen with the same method that I'm using to print in my code!
what's wrong with my code? I want my output to be the same as the input NAME.txt and not messed up like what I've shown
thanks alot