Hi I'm pretty new to programming started about 3 months ago, and even though I feel I'm getting better, I still find it not easy at all, I got especially trouble with that code, look I want to put into an array of strings sentences with spaces, etc.
At last I found out (ppl on this forum told me how) a way to write whole sentences and keep them complete and not just the first word.But now the problem is that I can't type the first line !!!The second, third,fourth,...X line is okay, but not the first it consistently "jumps" over it WHY?,WHY? and when I use rough integers like 4,5 the problem disappears, and as soon as I replace it with an int variable the problem comes again, I'm desperate please Help exam on monday, very important for me, please try the code and see for yourself and thanks of course the forum has already helped me a lot in these two days.
#include <iostream>
#include <string>
using namespace std;
void main(){
void main(){
int NS;
string sentence;
char charsentence[80];
cout<<"How many sentences ?"<<endl;
cin>>NS;
for(int i=0;i<NS;i++){
cout<<"Please enter sentence"<<i+1<<endl;
memset(charsentence,'\0',80);
getline(cin,sentence);
sentence.copy(charsentence,80);
}
}
}