Hello friends please look at this program, this program does not give any compilation error but pointer p2 not working here correctly
Complition 0 error and 0 warningCode:/* Created By Ravinder Kumar ,Pointer with string*/ #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char *p1; char *p2; char line1[50]="Hello i am rinku from ropar"; char line2[50]; puts(line1); /* This is okay and print the line1 */ p1=line1; puts(p1); /* This is also okay and print the line1 */ p2=line2; putchar('\n'); while(*p1 != '\0') { *p1++ = *p2++; } *p2='\0'; puts(line2); /* Actual error is here because No error is coming and nothing is printed but this statement is okay*/ return 0; }
[/CODE]
OUTPUT
Code:Hello i am rinku from ropar Hello i am rinku from ropar
Error with line2 string mean "char line2[50];" and after copy pointer first into pointer second nothing print in line2 which is pointed by pointer 2

Reply With Quote