Ask Question
20 October, 17:37

I'm new to programming and I'm starting with c++, so the first program I want to write should take a string of characters and output it to the console afterwards, but the execution isn't working, I can't find the issue.

'#include

#include

#include

using namespace std;

int main ()

{

short T;

cin >> T;

char * str;

//cin. clear ();

cin. sync ();

cin. ignore (1000, '/n');

while (cin >> * str++)

;

cin. sync ();

cin. ignore (1000, '/n');

while (*str + + ! = '/0')

cout << * str;

return 0;

}

'

+4
Answers (1)
  1. 20 October, 20:36
    0
    Just reading and writing a string should be as easy as:

    string msg;

    getline (cin, msg);

    cout << "Hello " << msg;

    return 0;
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “I'm new to programming and I'm starting with c++, so the first program I want to write should take a string of characters and output it to ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers