I am trying to solve e problem. I am taking characters as input and using gets()
. But the function is showing the above mentioned error.
I don't know why this function is misbehaving. Please help me to find the fault. I am a beginner.
As mentioned the error message is:
Use of undeclared identifier 'gets'
My C++ code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char line[1000];
bool open = true;
while (gets(line)) //***in this line gets() is showing error***
{
int len = strlen(line);
for (int i = 0; i < len; i++)
{
if (line[i] == '"')
{
if (open)
{
printf("``");
}
else
{
printf("''");
}
open = !open;
}
else
{
printf("%c", line[i]);
}
}
printf("\n");
}
return 0;
}