#include<iostream>
#include<ctype.h>
#include<string.h>
/*
Program to search for a given character inside a string and to print the string
from the point of the match.
the function should return nonzero if true,zero if false.
*/
usingnamespace std;
char *match(char,char*);
int main()
{
char str[80],ch,*p;
int i=0;
cout<<"Enter the char to search: ";
cin>>ch;
cout<<endl;
cout<<"Enter a string (max. 80 chars): ";
cin.getline (str,80);
cout<<endl;
p=NULL;
p=match(ch,str);
if(!*p)
{
cout<<"Found the character !!!\n";
for(char *count=p;*count!='\0';count++)
cout<<*count<<endl;
}
elseif(*p)
cout<<"Not found !!!\n";
cout<<"Thank you !!!\n";
return 0;
}
char *match(char a,char *str)
{
while((a!=*str) && (*str))
str++;
return (str);
}
The problem Im am having is tht cin.getline(str,80); wont input any text or whatsoever,and tht also after ive tried compiling it in various ways,like 3 times(std::cin.getline(..),etc,).I followed the tutorial here: http://www.cplusplus.com/reference/istream/istream/getline/
But after tht the program doesnt compile and Im at a dead end.Pls help guys.
Thnx in advance.