I have been working with this program for a long time now and I dont know how I can make it work.
The code is as follows:
Code:
#include <string.h>
#include <stdio.h>
int main ()
{
char input[80];
int i;
char stop[] = "STOP";
printf("Type a name:\n");
char array[][80]={"Kalle","Peter","Maxum","Einsten",
"Patrick Zen","Patrick Mark","Patricia Yrsa","Yrsan Dabom"};
for(;;)
{
scanf("%s",&input);
if(strcmp(stop,input)==0)
{
break;
}
for(i=0;i<8;i++)
{
if(strncmp(array[i],input,(unsigned)strlen(input))==0) {
printf("%s\n",array[i]);
}
}
}
}
This is my output.
Code:
Type a name: Patrick M
Patrick Zen
Patrick Mark
Maxum
If I type "Patrick M" I only want it to show me who has those 9 chars in it. Why doesnt it show me that?
Like I want my output to be like:
Code:
Type a name: Patrick M
Patrick Mark
It like ignores the space and start over?
Tell me if you want to explain it more.
- Lovelace