In c How do you access variable declared in main in other function?

1 answer

Answer

1278978

2026-04-01 09:45

+ Follow

Only if you pass a pointer to it, eg:

void sub (int *into)

{

*into= 3;

}

int main (void)

{

int myvariable;

sub (&myvariable);

return 0;

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.