c string not printing

closed account (1bfSwA7f)
hello,
I was wondering why my c string from my array was not printing?

code:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

void sentenceCapitalizer(char *ptr);

int main(){

const int MAX_SENTENCE_LENGTH = 200;
char userString[MAX_SENTENCE_LENGTH] = " no, not tonight. it's a very popular place \
and you have to make reservations in advance. besides, \
it's expensive, and I don't have any money.";

cin.getline(userString, MAX_SENTENCE_LENGTH);

cout << "The text before the modification: \n" << userString << '\n';

return 0;

}


output:

The text before the modification:
Last edited on
@osheik, please use code tags.

Your program DOES print:
1234
The text before the modification:
1234



> cin.getline(userString, MAX_SENTENCE_LENGTH);
So delete this line then, or make getline use a different char array.
closed account (1bfSwA7f)
tttt
Last edited on
Topic archived. No new replies allowed.