I'm working on basic pointers program om VISUAL STUDIO 2013:
#include <stdio.h>
void try1(char *c);
int main()
{
int stop;
char * c = "rotem";
try2(c);
printf_s(" %s \n \n ", c);
scanf_s("%d", &stop);
return 0;
}
void try2(char *c)
{
*c = (char)(*c + 1);
}
However, i get this messege:
Unhandled exception at 0x009F152A in Project32.exe: 0xC0000005: Access violation writing location 0x009F5860.
What should I do?
"rotem"
is a literal string, it is in read only memory, you cannot modify it
duplicate it, or use an array because in your case you do not need to increase its size replacing
char * c = "rotem";
by
char c[] = "rotem";
Also replace
void try1(char *c);
by
void try2(char *c);
User contributions licensed under CC BY-SA 3.0