首页 \ 问答 \ Linux内核编程:“无法处理内核NULL指针解除引用”(Linux Kernel Programming: “Unable to handle kernel NULL pointer dereference”)

Linux内核编程:“无法处理内核NULL指针解除引用”(Linux Kernel Programming: “Unable to handle kernel NULL pointer dereference”)

我正在写一个Linux模块(内核编程),我正在得到:

“无法处理内核NULL指针解除引用”

这是什么意思?


I'm writting a Linux module (Kernel Programming), and I`m getting:

"Unable to handle kernel NULL pointer dereference"

What does it mean?


原文:https://stackoverflow.com/questions/341422
更新时间:2022-04-24 08:04

最满意答案

如果要逐行遍历文件,可以打开文件,然后使用fscanf解析每一行。

fid = fopen(filename);

while true
    % Read the next 16 integers
    data = fscanf(fid, '%d', 16);

    % Go until we can't read anymore
    if isempty(data)
        break
    end
end

如果您希望每一行都作为字符串,则可以使用fgetl来获取每一行

fid = fopen(filename);

% Get the first line
line = fgetl(fid);

while line
    % Do thing

    % Get the next line
    line = fgetl(fid);
end

If you want to iterate through the file, line-by-line, you can open the file and then use fscanf to parse out each line.

fid = fopen(filename);

while true
    % Read the next 16 integers
    data = fscanf(fid, '%d', 16);

    % Go until we can't read anymore
    if isempty(data)
        break
    end
end

If you want each line as a string, you can instead use fgetl to get each line

fid = fopen(filename);

% Get the first line
line = fgetl(fid);

while line
    % Do thing

    % Get the next line
    line = fgetl(fid);
end

相关问答

更多