The code below won't compile from terminal window. Could you please help me understand why? This is the message I get when I try to compile:
/usr/bin/ld: /tmp/cclbzcmr.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0):
undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
The idea is simple, given the arguments from the command line, program should create files with the same names as those arguments and write the text the user enters in each of these files.
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
int i;
char text[1000];
FILE *p;
for(i=1;i<argc;i++){
char address[100]="/home/nikte/Documents/C++/MaraWorkspace/Zadatak1/";
printf("Enter your text:\n");
scanf("%s",text);
strcat(address,argv[i]);
p=fopen(address,"w");
if(p==NULL) printf("It is not possible to create your file %s\n",argv[i]);
else fprintf(p,"%s",text);
fclose(p);
}
return 0;
}
Thanks in advance!