Ho provato a implementare una funzione che prese due stringhe restituisce una sola stringa che è la concatenazione delle due.
es:
s1: ciao
s2: come stai
s: ciao come stai
mi da questo errore nella funzione subscripted value is neither array nor pointer
codice:
#include <stdio.h>
#define LUNG_STR 256
char _cp_string(char, char);
main()
{
char str1[LUNG_STR];
char str2[LUNG_STR];
int i;
for(i=0; i<LUNG_STR; i++)
str1[i]='\0';
scanf("%s", str1);
for(i=0; i<LUNG_STR; i++)
str2[i]='\0';
scanf("%s", str2);
printf("%s", _cp_string(str1[i], str2[i]));
return 0;
}
char _cp_string(char s1, char s2)
{
int p, c;
for(p=0; s1[p] != '\0'; p++)
;
for(c=0; (s1[p]=s2[c]) != '\0'; p++, c++)
;
return s1;
}
da cosa dipende?
grazie per gli eventuali chiarimenti!