![]() |
Where's the error? (C)
Hello, i am doing a project and I have a problem with the compilation. It says me that before the penultimate " } " there's an error. Culd you help me to find it?
Code:
#include <stdio.h> |
Re: Where's the error? (C)
Where is the 'while' which matches your 'do' ?
Also, use [code][/code] tags when posting code. |
Re: Where's the error? (C)
Hello Salemn. Ok, i understand the problem. But i have a new one about it: i want to fill todos_fich with the character strings in elementos.txt. So what should i include in while ( )?. I have tried while (fscanf(Elementos, "%s", todos_fich[i][j]);) != EOF), but it returns error...
|
Re: Where's the error? (C)
I'm sorry, I fortot using [code]: the thing I write (and doesn't work) is
[code] while (fscanf(Elementos, "%s", todos_fich[i][j]) !=EOF); |
Re: Where's the error? (C)
I have added the code block for you and you should start before the code with [code] and end it with [ /code]
|
Re: Where's the error? (C)
How do you know how many lines/words there are in the file?
> char todos_fich[i][2]; Aside from the fact that i is zero at this point, this doesn't create an array you can just extend at will. > for(j=0;j=1;j++) Refer to your book for proper syntax. Say for(j=0;j<2;j++) > fclose(elementos.txt); This takes the file handle, Elementos as the parameter. Passing Elementos as a parameter does no good. You'll get the same effect by making it a local variable. |
Re: Where's the error? (C)
Hello Salem/shabbir , the problem is that I haven't text book for study. I am Spanish and the only book I have been told to buy is the one writed by "Kernich"(may be wrong writed, I don't remember the exact name). But that book isn't in Spanish language, and I have considered ordering it in English, but I'm afraid of missunderstand some words leading me to important missconceptions.
Another think I'm interested in is that, as far as I know, matrixes are declared as, for example a matrix of inttegers: Code:
int mat[10][20]Code:
int *p=&matCode:
p=&mat[0]=&matCode:
*p=&mat[0]Code:
*(*p)Note: The only solve I find is doing malloc when declaring the pointer. If I do that, can I assure that those pointer to pointers are exactly the same than matrixes? Thanks a lot, you help me so much... |
Re: Where's the error? (C)
I recently posted how to allocate a 2D array here
http://www.go4expert.com/showthread.php?t=7759 |
| All times are GMT +5.5. The time now is 19:34. |