#Struggling with an assignment
1 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.
!f
#include <stdio.h>
#define PI 3.14159
int main(void) {
int radius;
printf(“Enter radius :”);
scanf(“% d”, &radius);
printf(“volume is : % d \n\n“, 4 * radius * radius * radius / 3);
return 0;
}
thanks
that not "
when you have an assignment they should have tought you something before?
again “ is not "
you need to use "
i am not OP
;compile
<source>:5:10: error: extended character “ is not valid in an identifier
5 | printf(“Enter radius :”);
| ^
<source>:5:25: error: extended character ” is not valid in an identifier
5 | printf(“Enter radius :”);
| ^
<source>:6:9: error: extended character “ is not valid in an identifier
6 | scanf(“% d”, &radius);
| ^
<source>:6:12: error: extended character ” is not valid in an identifier
6 | scanf(“% d”, &radius);
| ^
<source>:7:10: error: extended character “ is not valid in an identifier
7 | printf(“volume is : % d \n\n“, 4 * radius * radius * radius / 3);
| ^
<source>:7:27: error: stray '\' in program
7 | printf(“volume is : % d \n\n“, 4 * radius * radius * radius / 3);
| ^
<source>:7:29: error: stray '\' in program
7 | printf(“volume is : % d \n\n“, 4 * radius * radius * radius / 3);
|
like i said
i think that is one of the errors he is supposed to fix
that really really obvious
yes
@merry portal Has your question been resolved? If so, type !solved :)
there was another error when i did that
show code again
!f
#include <stdio.h>
#define PI 3.14159
int main(void) {
int radius;
printf("Enter radius:");
scanf("%d", &radius);
printf("volume is : %d \n\n", 4 * radius * radius * radius / 3);
return 0;
}
ok ok thanks
which error
!compile
bruh i hate it
;compile
2
#include <stdio.h>
#define PI 3.14159
int main(void) {
int radius;
printf("Enter radius:");
scanf("%d", &radius);
printf("volume is : %d \n\n", 4 * radius * radius * radius / 3);
return 0;
}
Enter radius:volume is : 10
here wait
./main.cpp:7:2: error: ignoring return value of function declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
7 | scanf("%d", &radius);
| ^~~~~ ~~~~~~~~~~~~~
1 error generated.
make: *** [Makefile:10: main] Error 1
!f
Nothing to format
cool
uhm yea thats the error im getting
std::ignore moment
?
but actually c++26 will just use
auto _ = scanf("%d", &radius);
@merry portal do not use this specificly, use above one
so that work?
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟
Upcoming Workshops:
► C++ Best Practices Workshop, CppCon, Aurora, CO, USA, Sept 13-14, 2025: https://cppcon.org/class-2025-best-practices/
► C++ Best Practices Workshop, NDC TechTown, Kongsberg, NO, Sept 22-23, 2025: https://ndctechtown.com/workshops/c-best-practices/e8e3819af0f6
CLion is a...
idk where to put it
the uhm
wait how do i format the code like this?
!code
```cpp
int main() {}
```
int main() {}
this part
scanf("%d", &radius);
ok, how you run your code, which ide do you use?
ye
!google ide
why you use it?
and anyway, can you show what you have on the folder structure?
its in my browser idk i couldnt figure out anything else with the next to zero research i did
the course provided one but it was broken or something
that's important?
yes, to show where you specify flags
do you on windows?
if no then clion, if yes then clion or Visual studio
okay
this?

ok, open terminal
one time i installed doom emacs on replit
so that trivial anyway
i dont see it
tbf just install clion or vs
What if scanf returns 0 or EOF? Does std::ignore take care of that?
think about it, what is EOF?
End of file or Buffer Error.
And still, what about 0. What if there is no readable input?
i mean, what it represented with
ignore ignoring
again
but also problem with specificly radius
I dunno whether C and C++ are different there. In C it would be system dependant, but most of the time EOF = -1
if you not read radius then it not good
yup
So std::ignore takes care of these cases?
Okay, cool, than it is unsafe, or not?
it safe
just look this
Okay, will check it out, thx^^
#include <stdio.h>
#define PI 3.14159
int main(void) {
int radius;
printf("Enter radius:");
scanf("%d", &radius);
printf("volume is : %d \n\n", 4 * radius * radius * radius / 3);
return 0;
}
!compile
