suzy Posted April 28, 2008 at 12:06 PM Report Share #181870 Posted April 28, 2008 at 12:06 PM Tenho o seguinte codigo #include <string.h> main() { FILE *fp; char str[50],**mat; fp=fopen("lol.txt","r"); int i,z=0; if(fp==NULL) { printf(" erro\n"); } mat=(char**)malloc(4*sizeof(char*)); for(i=0;i<50;i++){ mat[i]=(char*)malloc(sizeof(char)); } while(fscanf(fp,"%[^\n]",str)==1) { printf(" %s\n",str); mat[z++]=str; printf(" mat e %d\n",mat[z++]); } fclose(fp); fflush(stdin); getchar(); } basicamente, o que eu quero e ler de um ficheiro as strings e colocar um vetor de ponteiros a apontar para cada string. tipo: p[0]="portugal" p[1]="programar" acontece que neste codigo as strings nao "entram" no ponteiro, porque? Link to comment Share on other sites More sharing options...
suzy Posted April 28, 2008 at 12:22 PM Author Report Share #181872 Posted April 28, 2008 at 12:22 PM resolvido 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now