I wrote this code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *actionfpnt;
char* line[70];
actionfpnt = fopen(argv[1], "r");
if (actionfpnt == NULL)
{
printf("Error: opening %s failed
", "actions");
}
else
{
while (fgets(line, 70, actionfpnt) != NULL)
{
printf("%s
", line);
}
fclose(actionfpnt);
return 0;
}
}
while argv[1] is an address to a txt file, and in this text file:
Initialize
Fatal_malfunction $$$ cpu Zi7 $$$ 130
Fatal_malfunction $$$ cpu Zi5 $$$ 15
Returned_from_customer $$$ cpu Zi7 $$$ 10
Rename $$$ bloblo12zZzZ $$$ Zbloblo
Returned_from_customer $$$ Zblabla $$$ 10
Finalize
the confusing part is that the code actually working but when I try to debug it, I see in the variable "line" : "<error reading characters in string.>"
.
the output is:
Initialize
Fatal_malfunction $$$ cpu Zi7 $$$ 130
Fatal_malfunction $$$ cpu Zi5 $$$ 15
Returned_from_customer $$$ cpu Zi7 $$$ 10
Rename $$$ bloblo12zZzZ $$$ Zbloblo
Returned_from_customer $$$ Zblabla $$$ 10
Finalize
when I try to execute anything else with line, I cant because "line" doesnt really contain anything.
I would really appreciate a way to solve this issue, and an explenation to why the code worked and got the right output even with this issue.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…