user input fix

This commit is contained in:
Seth Samuel 2024-12-01 19:55:24 +13:00
parent 86cae67ee8
commit b37a846ed2
2 changed files with 12 additions and 16 deletions

BIN
puzzle1

Binary file not shown.

View file

@ -11,26 +11,22 @@ char stringTwo[stringSize];
int readIntoList(char* stringList){ int readIntoList(char* stringList){
int index = 0; int index = 0;
while(1){ while (1)
char next = getchar(); {
if (next != '\n'){ char next = getchar ();
stringList[index] = next; if (next == '.')
index++; {
}else{ break;
break; }
} else if (next != '\n')
} {
stringList[index] = next;
while (1) { index++;
readChar = getchar();
stringList[index] = readChar;
if (readChar == '\n' || index == stringSize-1) {
break;
} }
index++;
} }
} }
int main(){ int main(){
printf("enter list size: \n"); printf("enter list size: \n");