T_E Posted December 5, 2006 at 05:17 PM Report #68941 Posted December 5, 2006 at 05:17 PM #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string.h> main() { FILE *fp; /*fp- is a file pointer*/ char componente[10],referencia[10]; int no1,no2,valor1,valor2; /* open the file netlist.txt to read */ fp = fopen( "netlist1.txt", "r" ); if (fscanf(fp,"%s",&componente)) (componente[0]=='/'); printf("comment found"); while (fscanf( fp,"\n%s %s %d %d %d %d\n",&componente,&referencia,&no1,&no2,&valor1,&valor2)!=EOF) printf("\n%s %s %d %d %d %d\n",componente,referencia,no1,no2,valor1,valor2); /* close file */ fclose( fp ); } o programa tem por objectivo ler de um ficheiro os nos e dp introduzir um valor numa matriz.. componente|referencia | no1 | no2 |valor1 | valor2 UR | s |1 |0 |15 |1000 <----- este é o ficheiro de onde vai ler... R | a | 1 |2 |2200 | 0 R | b | 1 |3 |1500 |0 R | c | 2 |3 |4700 |0 R | d | 2 |0 |560 |0 R | e |3 |0 |3300 |0 tinha de imprimir uma coisa do tipo matriz[no1][no1]=+1/valor2 matriz[no2][no2]=+1/valor2 matriz[no1][no2]=-1/valor2 matriz[no2][no1]=-1/valor2 se alguem me puder ajudar!!!
Rui Carlos Posted December 5, 2006 at 08:20 PM Report #68998 Posted December 5, 2006 at 08:20 PM no 'fscanf' não devias ter '&componente' e '&referencia' mas apenas 'componente' e 'referencia'. Rui Carlos Gonçalves
Saco Posted December 5, 2006 at 08:43 PM Report #69005 Posted December 5, 2006 at 08:43 PM Não percebi qual é a dúvida... 😉
Hipnoted Posted December 5, 2006 at 09:19 PM Report #69020 Posted December 5, 2006 at 09:19 PM Não percebi qual é a dúvida... 😉 Sim, tens de ser mais explícito. tenta dizer como queres os dados e como te estão a aparecer. "Nunca discutas com um idiota. Eles arrastam-te até ao seu nível e depois ganham-te em experiência"
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