invalid conversion from 'int' to 'char *'

前端 未结 1 1086
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 19:54

I am suppose to write a program that will read from a text file and store what is inside the text file using structures and regroup and print out the information in the text fil

相关标签:
1条回答
  • 2021-01-25 20:19

    It seems that you are trying to read into non-strings with getline, whereas it is reading into strings as per documentation.

    Extracts characters from the stream as unformatted input and stores them into s as a c-string, until either the extracted character is the delimiting character, or n characters have been written to s (including the terminating null character).

    Here are two offending lines:

    infile.getline(info.no, MAX);
    

    and

    infile.getline(info.wishMessage, MAXNO, MAX);
    

    The former is reading into int, the latter is into a string array.

    You will need to first read the strings in, and then make the corresponding conversion operations as desired.

    0 讨论(0)
提交回复
热议问题