
Patrick B. answered 05/26/19
Math and computer tutor/teacher
When you pass the array, you are passing the BASE ADDRESS; that is, the address of the first element in the array.
Be careful now, char * p = "hello"; is dangerous. This is an unintialized pointer and you are using it.
Always use malloc and free for pointers like that.
Here's some code:
#include <stdio.h>
#include <stdlib.h>
void printSomething ( char * strMsgBuff)
{
printf(strMsgBuff);
}
int main()
{
char buff[255]=" Hello ";
char * strName = (char *)malloc(255);
if (strName==NULL) { return(-1); }
printSomething(buff);
printf(" What is your name ???? :>");
scanf("%s",strName);
sprintf( buff ," Hello %s \n",strName);
printSomething(buff);
free(strName);
}