43 lines
No EOL
892 B
C
43 lines
No EOL
892 B
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#define stringSize 20
|
|
|
|
int listSize = 0;
|
|
char readChar = '0';
|
|
char stringOne[stringSize];
|
|
char stringTwo[stringSize];
|
|
|
|
int readIntoList(char* stringList){
|
|
int index = 0;
|
|
|
|
while (getchar()=='\n'){
|
|
//eat up new lines in buffer
|
|
}
|
|
|
|
while (1) {
|
|
readChar = getchar();
|
|
stringList[index] = readChar;
|
|
if (readChar == '\n' || index == stringSize-1) {
|
|
break;
|
|
}
|
|
index++;
|
|
}
|
|
}
|
|
|
|
int main(){
|
|
printf("enter list size: \n");
|
|
|
|
scanf("%i", &listSize);
|
|
int listOne[listSize];
|
|
int listTwo[listSize];
|
|
|
|
memset (listOne, '\0', listSize);
|
|
memset (listTwo, '\0', listSize);
|
|
printf ("enter list 1: \n");
|
|
readIntoList (stringOne);
|
|
printf ("enter list 2: \n");
|
|
readIntoList (stringTwo);
|
|
|
|
printf ("one: %s \ntwo: %s ",stringOne,stringTwo);
|
|
} |