I have a small snippet of code here from something I designed but I keep getting the error :
sprintf not declared in scope
Do I include something in the #includes or how can I get this working? I was working on it on VS at my mom's but came home and I can't get it on code blocks
if (tmp2 <= B_dest[hr - 6])
{
sprintf(name, "B%d", tmp3);
}else{
sprintf(name, "A%d", tmp3);
}
You need to include stdio.h
.
#include<stdio.h>
The stdio.h
declares the function sprintf
, Without the header the compiler has no way of understand what sprintf
means and hence it gives you the error.
In C++ Note that,
Including cstdio
imports the symbol names in std
namespace and possibly in Global namespace.
Including stdio.h
imports the symbol names in Global namespace and possibly in std
namespace.
The same applies for all c-styled headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With