Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- char **ptr;
- ptr=calloc(10,sizeof(char));
- printf("\nEnter the Name : ");
- int val, i, j;
- unsigned char temp;
- while((val = getchar())!='\n'){
- printf("flag\n");
- //ptr[i] = (char) val;
- temp = (char) val;
- ptr[i] = &temp; //need to dereference this variable
- i++; //to assign to dynamic array
- }
- for (j=0; j<i; j++)
- printf("ptr[%d] = %s\n", i, ptr[i]);
- free(ptr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement