per quelche motivo a me oscuro questo prog produce output diverso su linux e sul macosx86 su intel
(mac su pc di casa non mac...)
se mi sapete spiegare il perche vi ringrazio molto .!! io non ne esco sto impazzendo..
grazie anticipatamente !!
macosx86----------
--->piove col sole
--->piove col mare
--->piove di notte
--->piove poco sole
---------------------------------
---> qipvf dom tome
---> (null)
---> qipvf ei!nptue
---> qipvf qodo!splf
---> // come si puo notare qui la stinga non viene stampata !!! =O
--->(null)
--->qipvf ei!nptue
--->qipvf qodo!splf
------------------------------------------------------------------------------------------------------
Linux-------
--->piove col sole
--->piove col mare
--->piove di notte
--->piove poco sole
---------------------------------
---> qipvf dom tome
---> (null)
---> qipvf ei!nptue
---> qipvf qodo!splf
---> qipvf dom tome // qui tutto ok !!!!
--->(null)
--->qipvf ei!nptue
--->qipvf qodo!splf
----->
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void funz(char **parray);
int main(){
int c;
char* str1 = calloc (10,(sizeof (char)));
char* str2 = calloc (10,(sizeof (char)));
char* str3 = calloc (10,(sizeof (char)));
char* str4 = calloc (10,(sizeof (char)));
char** stringa;
stringa = (char **) calloc (4,(sizeof (char*)));
strcpy(str1, "piove col sole");
strcpy(str2, "piove col mare");
strcpy(str3, "piove di notte");
strcpy(str4, "piove poco sole");
*stringa = str1;
*(stringa+1) = str2;
*(stringa+2) = str3;
*(stringa+3) = str4;
printf("\n\n\n");
printf("--->%s \n",*stringa);
printf("--->%s \n",*(stringa+1));
printf("--->%s \n",*(stringa+2));
printf("--->%s \n",*(stringa+3));
printf("---------------------------------\n");
funz(stringa);
printf("--->%s \n",*stringa);
printf("--->%s \n",*(stringa+1));
printf("--->%s \n",*(stringa+2));
printf("--->%s \n",*(stringa+3));
printf("---------------------------------\n");
}
void funz(char **array){
int c,d;
free (array[1]);
array [1] = NULL;
for (c = 0; c <= 3; c++){
if (array [c] != NULL){
d=0;
while (array [c][d] != '\0'){
array [c][d]++;
d+=2;
}
}
printf("---> %s\n", array[c] );
}
}
non risco ad allegare sorgente ...