Created
June 12, 2019 02:56
-
-
Save chrisdel101/796135782b1e06170354e0459afbff1d to your computer and use it in GitHub Desktop.
Unknown amount of command line inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define SIZE 50 | |
int main(void) | |
{ | |
char *str = malloc(SIZE); | |
puts("Enter name to search. Type Quit to exit."); | |
fgets(str, sizeof str, stdin); | |
while (strcmp(str, "quit\n") != 0) | |
{ | |
char tempStr[SIZE]; | |
fgets(tempStr, sizeof tempStr, stdin); | |
strncat(str, tempStr, strlen(tempStr)); | |
printf("tempStr %s\n", tempStr); | |
printf("str %s", str); | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment