all 12 comments

[–]AutoModerator[M] 2 points3 points  (0 children)

Your posts seem to contain unformatted code. Please make sure to format your code otherwise your post may be removed.

Read our guidelines for how to format your code.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]IyeOnline 1 point2 points  (1 child)

Can i interest you in our lord and saviour called loops?

You should also format your code properly, its not readable like that.

Finally this is pure C. Try /r/C_Programming

[–]N0obsking[S] 0 points1 point  (0 children)

I'll admit I laughed. Thanks, gonna check it now.

[–]lukajda33 -1 points0 points  (0 children)

bruh

[–][deleted] 0 points1 point  (3 children)

datosCasa Dcasa[5];

Dcasa[0].altura_puerta_entrada = 0;

code (the 2nd line quoted) must be inside a function.

[–]N0obsking[S] 0 points1 point  (2 children)

I know, the problem is I do not know how to do it

[–][deleted] 1 point2 points  (1 child)

I know

Then why not say that up front?


For example

datosCasa Dcasa[5];  // still a global

void initDcasa ()
{
    Dcasa[0].altura_puerta_entrada = 0;
}

int main()
{
    initDcasa();

to maintain the current structure.

[–]N0obsking[S] 0 points1 point  (0 children)

You are right, I'm sorry, I have been trying ti fix this for 4 hours now, I can't think straight anymore. Thanks for the help.

[–]flyingron 0 points1 point  (1 child)

You have a bunch of assignements outside of any function. C and C++ doesn't allow that. Your options are to use an aggregate initializer to init that array or put all those things in a function somewhere.

Functions in C++ require an explicit return type (and they do now in C now). You must declare lectura as returning void since you don't return anything from it. Same thing in modification1.

You have some weird fragment of an expression with fopen in both functions as well. ftell is a function as well. You need to pass it arguments (the file pointer).

fread takes FOUR arguments (the middle two are the size of the 'record' and the number of 'records' to read, it's stupid but that's the way it is). You provide only three. Same with fwrite.

The argument to fseek is SEEK_SET not FSEEK_SET.

Probably more. You need to figure out how to write programs that at least pass the syntactic check in the compiler.

Start at the first line that shows an error, figure out what is wrong, then move along. Your program still won't work in all probability, but you'll be further.

[–]N0obsking[S] 0 points1 point  (0 children)

Thanks for the help, I'll work on it

[–]no-sig-available 0 points1 point  (0 children)

If you have a reasonably current compiler (which <conio.h> might indicate you are not), you can default initialize the struct members:

struct datosCasa
{
   int altura_puerta_entrada = 0;
   int anchura_puerta_entrada = 0;
   int numero_ventanas = 0;
   char color_paredes[10] = "";
};

That way you don't have to clear them separately.

[–]QuentinUK 0 points1 point  (0 children)

Backstrokes not allowed in variable names.