【发布时间】:2015-05-13 09:25:49
【问题描述】:
我有一个文本文件:
hdsf5 sd3 htf2
使用指针 a、b、c 并使用它们可以正常工作.. 但是
用我的代码阅读这样的行没问题,但如果“sd3”这样丢失怎么办:
hdsf5 htf2
我将如何继续从文件中读取,即使在这种情况下指针会返回 null。
如果(b == NULL) 会很简单(指针在哪里就足够了?
编辑:我有这样的代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main (int argc, char * argv[])
{
FILE * ptr;
char str[100];
char * a, * b, * c;
//while loop using fgets...
// strtok each one...
//convert each one to an integer using (atol())
//this is where the seg fault/problem occur
}
【问题讨论】:
标签: c file printing segmentation-fault arguments