L
lili
Please forgive my poor english.The following is my code:
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char* teststr = "hello";
char* yes = teststr;
*(++yes) = 'w';
printf(yes);
}
-------*************************************************---------
print: segment error
Why did i got a 'segment error'?
but
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char teststr[20] = "hello";
char* yes = teststr;
*(++yes) = 'w';
printf(yes);
}
-------*************************************************---------
print: hwllo
or
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char* teststr = "hello";
char* yes = teststr;
printf("%c\n", *(++yes));
}
-------*************************************************---------
print: e
is no problem.
Can anyone help me , Thank you!
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char* teststr = "hello";
char* yes = teststr;
*(++yes) = 'w';
printf(yes);
}
-------*************************************************---------
print: segment error
Why did i got a 'segment error'?
but
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char teststr[20] = "hello";
char* yes = teststr;
*(++yes) = 'w';
printf(yes);
}
-------*************************************************---------
print: hwllo
or
-------*************************************************---------
#include <stdio.h>
#include <string.h>
int main()
{
char* teststr = "hello";
char* yes = teststr;
printf("%c\n", *(++yes));
}
-------*************************************************---------
print: e
is no problem.
Can anyone help me , Thank you!