#include <stdio.h>
#define K 1024
/** (2pts)
* Make a program that reads a line of input (up to 1024 characters,
using
* fgets,) and scans the input for the lowercase letter 'x'. If it
finds an x,
* it should print "The string has an x in it.\n" and exit, if it
does not, it
* should print "The string did not have an x in it.\n", then exit.
You may
* not use any standard library functions other than fgets for this
assignment.
*/
int main(void)
{
return 0;
}
#include <stdio.h> #define K 1024 /** (2pts) * Make a program that reads a line of input (up to 1024 characters, using * fgets,) and scans the input for the lowercase letter 'x'. If it finds an x, * it should print "The string has an x in it.\n" and exit, if it does not, it * should print "The string did not have an x in it.\n", then exit. You may * not use any standard library functions other than fgets for this assignment. */ int main(void) { int i = 0; char str[K]; fgets(str, K, stdin); while (str[i]) { if (str[i] == 'x') { printf("The string has an x in it.\n"); return 0; } i++; } printf("The string did not have an x in it.\n"); return 0; }
Get Answers For Free
Most questions answered within 1 hours.