C++: "Multi-character character constant" warning when reading from a file into char array

Augustas
#include <fstream>
#include <iostream>

using namespace std;

int main(){
    ifstream input;
    input.open("kr.txt");
    int n;
    input >> n;
    for(int i = 0; i < n; i++){
        char line[16];
        input.ignore(256, '/n');
        input.get(eil, 16);
    }

return 0;
}

I get the warning at the "input.ignore()". My file looks like this. 15 spaces separate the beginning of the line to the first number.

2
Rimas          195.5 45
Robertas       165 13
gordan.sikic

/n is constant consisting of two chars, '/' and 'n'and you are not quoting it as a string, using ", but as a char, using ', hence warning.

Maybe you wanted to use backslash instead of slash, i.e. '\n'?

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

how read char array(with some space) from file in c++

分類Dev

C++ Reading a file Char by Char into String; Crashes

分類Dev

C4838 warning with array initialization of a const char* array

分類Dev

C - Reading from a file with threads

分類Dev

reading from a binary file in C

分類Dev

Reading objects into array from file and vice versa

分類Dev

Reading from an Input File to an Integer Array

分類Dev

Reading Strings from a file to an ArrayList then converting to an Array

分類Dev

Multi-character warning while get a char from keyboard in c

分類Dev

Issues when reading from a .cpp file

分類Dev

Reading from a binary file when closing and opening it

分類Dev

Any advice for reading in char arrays from text files in C?

分類Dev

How to fix "undefined" array when reading a file into an array with readFile

分類Dev

Reading ASCII characters from a file in C

分類Dev

Reading from a file C++ Ifstream

分類Dev

C - Reading a string & int from stdin (or redirect from file)

分類Dev

C *char pointer to char array

分類Dev

Reading a .CSV file in C

分類Dev

Sscanf in C - reading numbers from a .txt. file

分類Dev

Trouble reading row of doubles from file C++

分類Dev

C: Symbols in array of char

分類Dev

Reading picture from byte array

分類Dev

Reading short from byte array

分類Dev

Reading numbers from textfile into array

分類Dev

Reading variable from txt file

分類Dev

Reading from a txt file in Java

分類Dev

Reading from file stops working

分類Dev

Reading a file from resource package

分類Dev

Reading from a text file not working