- 1
How to enter a word in CPP in Variable - "char name[20]" ?
In my school and home pc CPP Borland compiler gets(); function is working well but in sololearn learn, it is not working. So can you help me to get a suitable function.
8 odpowiedzi
+ 1
use fgets() instead.
+ 1
It's better if you can share your code here so it is easy to help. Or else the discussion will never end.
+ 1
Your code has a lot of errors and unnecessary lines that will never be accepted in the challenge.
Also this is how you use it-
fgets(sentence, 200, stdin);
- 1
I had tried but not works
- 1
What is its header file
- 1
Ok
- 1
#include <iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int main() {
system("cls");
char sentence[200],alienS[200];
int i=0,sos; //sos=size of sentence
cout<<" Human Language : ";
fgets(sentence );
for(sos=1;sentence[sos]!='\0';sos++);
for(sos,i;sos>=0;sos--,i++)
alienS[i]=sentence[sos];
cout<<"\n\n Alien's Language : "<<alienS;
return 0;
}