I am writing a code in which the function "verif" is supposed to verify whether the characters differ in a string or not. This function is then called for each line in a file. However, although i verified and the function is ok, there is something i am doing wrong concerning the returning of pointers or the attribution in the main function. The result i get is 'null null null' for each line of the file ( my file has 3 lines) This is my code:
#include <stdio.h>
#include <stdlib.h>
char* verif (char line[])
{
int i,j,ok=1;
char v[5];
for (i=0; i<strlen(line); i++)
{
for (j=i+1; j<strlen(line); j++)
{
if (line[i]==line[j])
{
ok=0;
break;
}
}
}
if (ok==0) strcpy(v,"No");
else strcpy(v,"Yes");
return v;
}
int main()
{
FILE *f;
char sir[30];
char* ctrl;
if ((f=fopen("fis.txt","r"))==NULL) exit(1);
while (fscanf(f,"%[^\n]",sir))
{
if (fgetc(f)==EOF) break;
puts(sir);
ctrl=verif(sir);
printf("%s",*ctrl);}
}