← Back to topics
Topic

C++ Help

f
frank44
Hi I"m new to C++ and I'm trying to learn how to use the stdio functions. Could anyone tell me why I get "Invalid Memory Reference (memory limit exceeded)" in my latest z-processor submission? I can't find my error.
a
adminModerator
scanf("%s", c)

expects c to be of type
char * c
and not string

char* is c type null terminated string.

Let me know if you want more details on why exactly you get bad memory reference error
f
frank44
Oh I see, thanks I'll keep that in mind.
M
MilosRadic
got a problem with stdio also cause when i write smt like this
for(i=0;i<5;i++) scanf("%d\n",a)
...
the program keeps w8ing
it does not execute cause it is w8ing for smt to read cayse of \n and then i just type smt random and its ok...
but how can i avoid this?
m
matteo123
this is wrong: scanf ( "%d\n", a ). you have to write it like this: scanf ( "%d\n", &a );
M
MilosRadic
ok i forgot about that:D
i do it right but how can i avoid this new line problem???:S
A
AKI_SER

for(var i=0;i<5;i++)
scanf("%d",a);

Try it like this.
You told the compiler it should search the input for an integer and a new line, so it would always wait for you to enter the numbers 5 times in separate lines.