N
Nicholas
At the end of the while loop, I would like to know that the integer values
are two, other symbol is one.
Integers: 3500 and 5
Other symbol: *
char*pt = "3500*5";
char numbuf[30];
int i;
// Counting the other symbols and integers
int others, integers;
Inside the function:
while (*ptr != '\0') {
if (isdigit(*ptr)) {
while (*ptr != '\0') { // Is it alright ?
// Need to 'peek' to the next one before -**- it if is integer
// If it is not integer, reset to the original ptr
numbuf = *pt;
i++;
ptr++;
}
integers++;
}
else // It is another symbol
other++;
ptr++; // -**-
}
printf("Integers: %d\n", integers);
printf("Other symbols: %d\n", others);
Thank you for the comments
are two, other symbol is one.
Integers: 3500 and 5
Other symbol: *
char*pt = "3500*5";
char numbuf[30];
int i;
// Counting the other symbols and integers
int others, integers;
Inside the function:
while (*ptr != '\0') {
if (isdigit(*ptr)) {
while (*ptr != '\0') { // Is it alright ?
// Need to 'peek' to the next one before -**- it if is integer
// If it is not integer, reset to the original ptr
numbuf = *pt;
i++;
ptr++;
}
integers++;
}
else // It is another symbol
other++;
ptr++; // -**-
}
printf("Integers: %d\n", integers);
printf("Other symbols: %d\n", others);
Thank you for the comments