Thank you MK27
I corrected the things that you pointed out. However things don't run smoothly.
I managed to get the code from the VMware:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
char *genCallNr();
typedef struct call
{
int date1;
int qty;
char contract[100], owner[100], partnr[100];
char* callnr;
} CALL;
int main(void)
{
CALL c;
strcpy(c.contract, "DELL");
strcpy(c.owner, "EMEA");
strcpy(c.partnr, "615TW");
c.callnr = genCallNr();
printf("%s\t%s\t%s\t%s", c.contract, c.owner, c.partnr, c.callnr);
free (c.callnr);
}
char *genCallNr(){
char callnr = malloc(11);
time_t now;
struct tm *ts;
char buf[80];
//char callnr[11];
now = time(NULL);
ts = localtime(&now);
strftime(buf, sizeof(buf), "1%y%m%d%H%m", ts);
printf("\n%s", buf);
strncpy(callnr, buf,80);
printf("\n%s", callnr);
return callnr;
}
I get segmentation fault. Any idea why ?