I'm trying to read strings in from a file that was inputed from the user and print them on separate lines I need to make sure that there are no non printable characters in the string. if there are non printable characters skip to the next string. A string in this should be greater than 4 characters and null terminated. I have:
Code:
#include <stdio.h>
#include <string.h>
char fname[150];
char *p;
FILE *in_file;
int main(){
printf("Enter a filename: ");
if(fgets(fname,sizeof(fname),stdin) != NULL){
if((p=strchr(fname, '\n')) != NULL)
*p = '\0'
}
in_file = fopen(fname,"r");
if(in_file == NULL){
printf("Cannot open %s \n", fname);
exit(8);
}
This opens the file for reading. I assume that a function to read a string that does not contain a non printable character and print it, in a loop would work fine here, but I don't know how to check if there are non printable characters/ skip to the next string.

I feel like a noob lol