#include <stdio.h> #include <stdlib.h> int main(void) { //char s[6] = {'h','e','l','l','o','\0'}; char *s = "hello"; int i=0,m; char temp; int n = strlen(s); //s[n] = '\0'; while (i<(n/2)) { temp = *(s+i); //uses the null character as the temporary storage. *(s+i) = *(s+ni-1); *(s+ni-1) = temp; i++; } printf("rev string = %s\n",s); system("PAUSE"); return 0; }
When compiling, an error is a segmentation error (access violation). Tell me the difference between the two definitions:
char s[6] = {'h','e','l','l','o','\0'}; char *s = "hello";
c
Surya
source share