I've a little problem with a little program and I can't figure out what the problem is and how to solve it.
Purpose of the program:
open a .csv file
read a line
split the string (delimiter = ; ) and store the substrings.
Sounds easy, however: it won't run, it doesn't give errors and while debugging it says:
Unhandled exception at 0x102aece9 in LetsTest.exe: 0xC0000005: Access violation writing location 0x00000000.
when jumping to strcpy().
Who can help me? It's a subfunction of a bigger project with a deadline way too soon!
Thank you very much,
you have initialised copy to be a NULL (0) pointer and in line
19 you try copying to it !!!! hence the access violation.
you don't need the strcpy function in line 19 because line.c_str returns a char*.
So change line 19 to copy= (char*)line.c_str(); .
You may need the cast because line.c_str returns a constpointer .
I used a 'C' style cast, but the c++ way copy= const_cast <char*>line.c_str(); maybe the more official way to do it.