#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Int
Main (void)
{
Char str[512];
Char *endpstr;
int N;
struct Struct_num {
int highs[n];
int violate[n];
};
struct Struct_num num;
/* Get n */
scanf ("%d", &n);
GetChar ();
/* Get Height data */
Fgets (str, stdin);
Endpstr = str;
int cur = 0
/* while (ENDPSTR) {*/
/* num.highs[i++] = strtol (Endpstr, &ENDPSTR, 10); */
/* printf ("%d\n", Strtol (Endpstr, &ENDPSTR, 10)); */
;
/* } */
return 0;
}
This code can be compiled through, but, as long as I put 512, replaced by 1024,1022, will get
Segmentation fault (core dumped)
No need for me to input, direct display error OH
If the transfer
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Int
Main (void)
{
Char str[1024];
Char *endpstr;
int N;
struct Struct_num {
int highs[n];
int violate[n];
};
int cur;
struct Struct_num num;
/* Get n */
scanf ("%d", &n);
GetChar ();
/* Get Height data */
Fgets (str, 1024x768, stdin);
Endpstr = str;
cur = 0;
while (ENDPSTR) {
/* num.highs[i++] = strtol (Endpstr, &ENDPSTR, 10); */
printf ("%d\n", Strtol (Endpstr, &ENDPSTR, 10));
/* ; */
}
return 0;
}
The error that will be displayed is:
Bus error (Core dumped)
If you switch to 512, you will be able to compile and pass. Why is this?
A mistake in C, not finding out why.