Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
Created June 12, 2019 02:56
Show Gist options
  • Save chrisdel101/796135782b1e06170354e0459afbff1d to your computer and use it in GitHub Desktop.
Save chrisdel101/796135782b1e06170354e0459afbff1d to your computer and use it in GitHub Desktop.
Unknown amount of command line inputs
#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