Function argument treated as undeclared
Posted
by Mikulas Dite
on Stack Overflow
See other posts from Stack Overflow
or by Mikulas Dite
Published on 2010-05-31T17:55:14Z
Indexed on
2010/05/31
18:03 UTC
Read the original article
Hit count: 189
c
I've prepared this simple example which is not working for me
#include <stdio.h>
#include <stdlib.h>
FILE *fp;
char filename[] = "damy.txt";
void echo (char[] text)
{
fp = fopen(filename, "a");
fwrite(text, 1, strlen(text), fp);
fclose(fp);
printf(text);
}
int main ()
{
echo("foo bar");
return 0;
}
It's supposed to write both to command window and to file. However, this gives compilation error - the text
used in echo() is not declared. Does c need another declaration of the variable?
© Stack Overflow or respective owner