Anonymous
i mainly use gcc with clangd
Im using Ubuntu now and my code has no colors
Anonymous
Visual studio code
klimi
yeah... i don't know, maybe you need a plugin in VSC ? not sure... i use neovim...
Anonymous
hey, i have c++ 14 how do i get version 17? do i need to uninstall and then install it?
Anonymous
use --std=c++17 while compiling
i wanna make it permanent i use sublime how do i do that?
klimi
no idea, you should know how your editor works.... i guess there is some make instructions, so you would have to modify that file, maybe google can help, no idea
klimi
i wanna make it permanent i use sublime how do i do that?
https://blog.codingblocks.com/2019/setting-up-a-c-competitive-programming-environment/ the point 3
Anonymous
klimi
oh i have my own build system so we can just replace it huh
i guess? i don't know how it works, but it sounds ok
Anonymous
i tested with a c++17 exclusive code
klimi
what's your compiler?
klimi
version?
Anonymous
version?
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
klimi
g++ (MinGW.org GCC-6.3.0-1) 6.3.0
you can look in this https://gcc.gnu.org/projects/cxx-status.html to find what version of g++ you need, but if i am not looking wrong, mainly C++17 features got implemented in version 7
klimi
yea so do i uninstall and install 7?
current version of g++ is 11
Anonymous
Anonymous
You just update it.
https://stackoverflow.com/questions/9865319/how-to-update-gcc-in-mingw-on-windows#:~:text=Run%20the%20command,will%20be%20upgraded. This?
Anonymous
Yes you can try that.
did it still: gcc (MinGW.org GCC-6.3.0-1) 6.3.0 (as before)
Anonymous
#include <stdio.h> int main() { int num,i; long int fact; printf("Enter an integer number: "); scanf("%d",&num); /*product of numbers from num to 1*/ fact=1; for(i=num; i>=1; i--) fact=fact*i; printf("\nFactorial of %d is = %ld",num,fact); return 0; } How can I make it to be able to give huge numbers output It sounds it is limited for 10 digits only
klimi
and if you need ever bigger, you will have to use some libraries for big integers
Anonymous
did it still: gcc (MinGW.org GCC-6.3.0-1) 6.3.0 (as before)
Did it give you an error or did it now show any packages for upgrade?
Anonymous
it didnt throw any error
Not sure then. I dont use mingw. So cant be of much help.
Ayush
Hey i am beginner of c programming can anyone give me tips?
Look at "Learn C the hard way by zed shaw" I'm following it and it is really a good book. Second one is "Data structures through C in depth by sk srivastava"
Anonymous
I want it to find 200!
Use gmp library then
klimi
I want it to find 200!
um.... you will need bigger data type :)
Ravi
I want it to find 200!
Use array of size 1000, do 1 2 3 .....upto 200 numbers multiplication using traditional digit wise multiplication.
king king
guys i beg you
Anonymous
did it still: gcc (MinGW.org GCC-6.3.0-1) 6.3.0 (as before)
mingw for windows is built by various different people and teams, you need to know if the distributors of the one you use have any updates available
Anonymous
https://www.msys2.org/ have up to date versions most of the time
Anonymous
https://www.msys2.org/ have up to date versions most of the time
Even that seems old. They currently support only 9. GCC has already released nightly builds of version 12 with C++23 support. Not sure if it is a good idea to use mingw on Windows. Why dont people use Visual Studio? Size issues?
Anonymous
msvc does an awful job at codegen https://gcc.godbolt.org/z/PGYebMeGv
That seems weird. On my test computer it seems to be generating the same assembly code as GCC does when I compiled it with /O2
...
That seems weird. On my test computer it seems to be generating the same assembly code as GCC does when I compiled it with /O2
i think the x64 version didn't have this problem, i've seen this exact codegen when reverse engineering something that was compiled with msvc so this must be some kind of problem i guess?
Anonymous
How can I add libraries for c in android?
Dumb
I don't know, you should ask in an android group They could help you if you can't get anything here
Anonymous
Use gmp library then
I don't to change something? Just using that Libra is enough?
Anonymous
I dont follow you.
I mean I should use the gmp library So the prgram can return more than 10 digits
Anonymous
??
Anonymous
I mean I should use the gmp library So the prgram can return more than 10 digits
I suggested gmp for calculating 200!. That has close to 375 digits. You need to use the arbitrary precision integer defined in gmp library to do your calculations instead of using the built in types in C++
Ehsan
does anyone have mac and know how to install boost with CMake
kc
https://github.com/microsoft/vcpkg
Anonymous
how do i get std::initializer_list to preserve it's data? https://rextester.com/WUM88022
Manu
Guys, i am new in c++ anyone help me how to start
Manu
And with whom
Anonymous
how do i get std::initializer_list to preserve it's data? https://rextester.com/WUM88022
You cannot return a initializer_list. A initializer_list likes a reference to a implicit read-only local array. Return it like return a reference to a local object. You can use vector instead.
Spirit
Use a vm and install gentoo
Anonymous
I want to make a simple calculator, What's wrong in this code? #include <stdio.h> int main() { int num1,num2,value; char op; printf("Enter a number: "); scanf("%d", &num1); printf("Enter an operator [d = /, m = *, a = *, s = - ]: "); scanf("%c",&op); printf("Enter another number: "); scanf("%d", &num2); if (op = d), value = num1/num2; if (op = m), value = num1*num2; if (op = a), value = num1+num2; if (op = s), value = num1-num2; printf("Answer = %d", value); return 0; }
Official hooligan of Pius XII
also keep in mind that dividing two integeres won't give you correct fractions
Anonymous
can you edit this code plz
Official hooligan of Pius XII
just do if(op=='s') and so on
Anonymous
main.c:25:15: error: ‘d’ undeclared (first use in this function) if (op == d), value = num1/num2; it shows this error
Official hooligan of Pius XII
also keep in mind that dividing two integeres won't give you correct fractions
and if you care about fractions, store the numbers as float/double type
Official hooligan of Pius XII
"d" -> string literal 'd' -> char d -> variable named d
Anonymous
Here's modified code, still it shows errors #include <stdio.h> int main() { int num1,num2; float value; char op; printf("Enter a number: "); scanf("%d", &num1); printf("Enter an operator [d = /, m = *, a = +, s = - ]: "); scanf("%c",&op); printf("Enter another number: "); scanf("%d", &num2); if (op == "d"), value = num1/num2; if (op == "m"), value = num1*num2; if (op == "d"), value = num1+num2; if (op == "s"), value = num1-num2; printf("Answer = %f", value); return 0; }
Official hooligan of Pius XII
Here's modified code, still it shows errors #include <stdio.h> int main() { int num1,num2; float value; char op; printf("Enter a number: "); scanf("%d", &num1); printf("Enter an operator [d = /, m = *, a = +, s = - ]: "); scanf("%c",&op); printf("Enter another number: "); scanf("%d", &num2); if (op == "d"), value = num1/num2; if (op == "m"), value = num1*num2; if (op == "d"), value = num1+num2; if (op == "s"), value = num1-num2; printf("Answer = %f", value); return 0; }
1) When using char type, you have to use single ', not double ". 2) Don't make commas , after if statement. You can make no brackets {} when executing just one line but still, no place for commas like that Here's the correct part of the code: if (op == 'd') value = num1/num2; if (op == 'm') value = num1*num2; if (op == 'd') value = num1+num2; if (op == 's') value = num1-num2;
Anonymous
int main() { int num1,num2; float value; char op; printf("Enter a number: "); scanf("%d", &num1); printf("Enter an operator [d = /, m = *, a = +, s = - ]: "); scanf("%c",&op); printf("Enter another number: "); scanf("%d", &num2); if (op = 'd') value = num1/num2; if (op = 'm') value = num1*num2; if (op = 'd') value = num1+num2; if (op = 's') value = num1-num2; printf("Answer = %f", value); The underlined lines are not running, what's the reason?
Anonymous
Enter a number: 3 Enter an operator [d = /, m = *, a = +, s = - ]: Enter another number: m ...Program finished with exit code 0 Press ENTER to exit console.