Expand|Select|Wrap|Line Numbers
- # include <stdio.h>
- # include <string.h>
- int main(void)
- {
- printf("Fine at line 6");
- FILE *source;
- char string1[10];
- int safety=0;
- printf("Fine at line 11");
- source = fopen("sourcetext.txt", "r" );
- printf("Fine at line 16");
- string1[0] = getc(source); //using fgetc yields the same result. Removal of this line results in the program running fine.
- printf("%c",string1[0]);
- fclose(source);
- return 0;
- }
Expand|Select|Wrap|Line Numbers
- 17 [main] syntax 4100 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
- Segmentation fault (core dumped)
Expand|Select|Wrap|Line Numbers
- Exception: STATUS_ACCESS_VIOLATION at eip=610E67EE
- eax=0022D008 ebx=00000000 ecx=611010E8 edx=FFFFFFFF esi=611001A0 edi=00000064
- ebp=0022CC58 esp=0022CC40 program=c:\Users\OwnerHP\syntax.exe, pid 4100, thread main
- cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
- Stack trace:
- Frame Function Args
- 0022CC58 610E67EE (00000000, 0040201F, 00401050, 00401075)
- 0022CCC8 61092D88 (00000001, 61169690, 00FA0090, 0022CC60)
- 0022CD78 61006198 (00000000, 0022CDB0, 61005510, 0022CDB0)
- 61005510 61004416 (0000009C, A02404C7, E8611001, FFFFFF48)
- 17 [main] syntax 4100 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
What can I do to get this to run, and why is it crashing? I got a similar one to run a while earlier that took the characters retrieved from the file, counted them, and checked to see if there was a certain set, at which point it would stop and print how many characters it saw before the pattern at the end of the file.