- To: slug@xxxxxxxxxxx
- Subject: [SLUG] C Gurus
- From: ashley maher <ashley.maher@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 22 Nov 2005 13:26:24 +1100
- Organization: Didymo Designs
- Reply-to: ashley.maher@xxxxxxxxxxxxxxxxxxxx
G'day,
I know this is not even C 101 level but would some kind soul please
explain to me why this is not even close to working.
Regards,
Ashley
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int somefunction(char *string1)
{
char *string2 = "some words\0";
string1 = (char *)calloc(strlen(string2 + 1), sizeof (char));
strcpy(string1, string2);
return 0;
}
int main ()
{
char *string;
somefunction(string);
printf ("\n\nString is: %s\n\n", string);
free (string);
return 0;
}