#need help with an error occuring in code
67 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
printf takes a format first and then it takes the values, example coming:
the %c %d thing?
int a = 1;
int b = 2;
printf("%d + %d = %d", a, b, a + b);
indeed
int a =30;
int b = a+5;
int c =b+1, e;
printf ("%d", a , "%d" , b , "%d", c , "%d", e)
is this the correct way?
no, first comes the format as the first argument, then come the values
hmm
printf(formatString, ...values)
also, what are you trying to achieve with int c =b+1, e;
int a =30;
int b = a+5;
int c =b+1, e;
printf ("%d , %d , %d, %d", a , b, c, e)
i wass looking at a tutorial and it was showing how one can declare e too as a variable but not assiging any value to it
ah, that's indeed what that does
yes sir!
tysm for the help!
nw
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
#include<stdio.h>
int main(){
int a=30;
int b=a+5;
int c= b+1, e;
printf("%d , %d , %d, %d", a , b, c, e);
}```
it is still showing the same problem tho
argument of type "int" is incompatible with parameter of type "const char *"
no im just running this
your intellisense might not yet have caught up
im a beginner
how are you running it
gcc
show your process
are you running it or is it just showing that before running
this is before running
and this comes after running
your instructions.c file doesn't exist
gcc must be run in the same folder where the c file is
or you must specify the full path to the folder where it is + the c file
hmm i think you are right
im typing the name wrong
its instruction.c
💀
one more question
the e variable dont have a value assigned
why is e coming as 4200816?
well yesn't, you didn't initialize it
it did make space on your memory for it.
that means that whatever was there before you made space for it in memory will be shown
i.e. useless garbage
hence why you'd always want to set a value before using a variable
or you'll get something random
wait
so like the space it was assigned to it
previously haad 4200816 stored in it
and thats why it got printed//
?
np
It’s undefined behavior. Maybe that was a value that was stored there previously, or maybe not. It could be a value filled by the OS or literally anything else
Alright thanks!