C
C
CodeInside2015-10-31 18:00:12
C++ / C#
CodeInside, 2015-10-31 18:00:12

Why is the string output in the wrong encoding?

There is a file "questions.txt". File content:
When do you have to make a block diagram of the program?
Which program provides translation of programs with high-level language into the language of a lower level?
The algorithm , in which the actions are performed one after the other , without repeating is called:
For the squaring function is used :
...

bool readQuestions(string address,string* qPointer)//считывает вопросы с файла по полученному адресу и записывает их в строки указателя
{
  ifstream fQuestions(address);

  if(!fQuestions)//проверка на наличие файла
  {
    printf("Error: file '%s' not found!\n\n",address);
    return false;
  }

  for(int i =0; i< 15; i++, qPointer++)//15 вопросов
  {
    getline(fQuestions,*qPointer);//считывание и запись строки
  }
  return true;
}

Call:
string question[15];//тексты вопросов
readQuestions("questions.txt",question);

After initializing this line through the function, strange characters are displayed, and as I understand it, the lines were read up to a space, and not up to '\n'. How can I fix this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question