gets not working

why gets() is not working ?

here's the function code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int searchStr(char **Str, int &size)
{
	char word[15];

	cout<<"enter the word to search: ";
	gets(word);
	char wantedWord[15];

	strcpy(wantedWord,"yoni");

	for(int x=0; x<size; x++)
	{
		if(strcmp(Str[x],wantedWord))
			return 1;
		else
			return 0;
	}
}
Do not mix <iostream> with <cstdio> in your code. Use one or the other, preferably <iostream>.

Just use cin >> word; also, you should use std::string variables, they're much simpler!
http://www.cplusplus.com/reference/string/string/
Last edited on
Topic archived. No new replies allowed.