Answer the question
In order to leave comments, you need to log in
How to add a check for the absence of spaces in C?
Hello, I have a code that takes a serial input of characters as input and converts the characters to hexadecimal. ignoring spaces.
#include <stdio.h>
int decod (void);
int main() {
decod();
}
int decod (void) {
int s;
while ((s = getchar()) != '\n') {
if (s != ' ') {
printf("%X ", s);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Set the error flag before checking. At the first space (more precisely, at each) reset the flag.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question