Xudoyberdi
Al
In C Pi is defined in math.h: #define M_PI 3.14159265358979323846
Vitalii
#include <stdio.h> int main() { int x=3; FILE * text = fopen("texst.txt", "r"); fscanf(text, "%d", &x); printf("%d", x); fclose(text); return 0; } Sorry, I have number "5" in my text file. Why it prints "3", but not 5?....
Vitalii
simple example, but I have no clue why it doesn't work
olli
And I couldn't add in path, in fact, I couldn't understand what is path.
Your path is part of the environment variables. When you start an application it is looked up in your current directory or in your path. To be able to build from within any folder, you either need to specify the full path to your compiler or add it to your path. It doesn't matter where VSCode is installed to, your compiler doesn't need to know, but VSCode needs to compile your code and need to know where your compiler is. In Windows, search for "Edit the system environment variables", the "System Properties" open with the "Advanced" Tab selected. Select "Enviroment Variables..." look for "Path" inside the System variables, select and click "Edit..." and add your compiler to it (e.g. C:\MinGW\bin)
Anonymous
I have a small doubt
Anonymous
with the break statement does this break break the while loop or breaks the if? vector<int> primeraparteizquierda (vector<int> s){ vector<int> res; int i = 0; while(i < s.size()){ if(sumatoria(res,0,i) <= sumatoria(s,0,i)){ res.push_back(s[i]); i++; }else{ break; } } return res; }
Danil
The if statement is not breakable
Anonymous
how do check if char* is a digit in c
olli
how do check if char* is a digit in c
https://en.cppreference.com/w/c/string/byte/isdigit
Anonymous
https://en.cppreference.com/w/c/string/byte/isdigit
isdigit only works with a char i want to use it with char*
olli
isdigit only works with a char i want to use it with char*
Why check whether the pointer is a digit? But this code returns 1 #include <stdint.h> #include <ctype.h> int main() { char *A = (char*)(uintptr_t)'1'; return isdigit((unsigned char)((uintptr_t)A)); }
olli
thnx
why tho? that screams bad practice and potentially UB
olli
whats the better approach
what do you want to do? E.g. to use pointers only for objects / function it points to and not to store digits
olli
whats the better approach
or do you mean this? #include <stdint.h> #include <ctype.h> int main() { char X = '0'; char *A = &X; return isdigit(*A); }
Anonymous
this is what i am doing
typedef char *string; int main(int argc, string argv[]) { if (argc > 1 && isdigit(argv[1])<MAX_PERSONS ) { printf("%s", "all set"); } // printf("%d", argc); // Person People[MAX_PERSONS]; }
Anonymous
I made a half poker game IN C!
Tintin
I made a half poker game IN C!
That's awesome. Are you planning to release the code?
SALIHU
Hello everyone, I'm new here🙂, hope to get alon with y'all
Xudoyberdi
Junaid
How is the way to split highest numbers in array
klimi
How is the way to split highest numbers in array
Like split array in half based on where us the highest value?
Junaid
If we have array 5678 so 8 become 7, 1
klimi
So you just fond the highest number and you split it into [n-1, 1]?
Junaid
So you just fond the highest number and you split it into [n-1, 1]?
While splitting up as 7,1( 7 is second highest)
klimi
I see
klimi
Then you need to find 2 maximums and just split the highest
Anonymous
hi how can i write recursive function for powering all numbers(2^1, 2^-1 , 2^0)?
SALIHU
/get cppbookguide
Rahul
/get
Z
/get
Z
/get
Z
/get
Anonymous
/notes
Anonymous
#imhacker
Henry
/get vscodesetup101
Jasur Fozilov 🐳
/get cpp
Jasur Fozilov 🐳
/get cbook
Anonymous
Loop
Anonymous
Pyramid shape loop coding
Anonymous
Anyone send me loop code pyramid shape
christian
i don't seem to understand he difference between recursive and inline functions, anyone to explain to me?
Anonymous
Use two loops like we do for matrix Conditions like first loop when equal to second loop value and all you can define bro The inner line can be used when first loop divide by 2 and second will just print
Anonymous
Plzzzz coding me
olli
i don't seem to understand he difference between recursive and inline functions, anyone to explain to me?
What do you mean by "inline"? inline is a keyword of the C/C++ programming language that serves as a hint for the compiler to perform certain optimization. Recursion having a function calling itself.
olli
Inline functions type of functions called inline functions
How do you think inlined functions and recursion are related? In one case you have a function that calls itself, most likely executing the function entry multiple times. In the other case you have an optimization where the compiler places the code of a function a into the caller to avoid a function call. You can think of inlining as writing everything into a single function.
Mino
Someone know How can I create and array empty and then add the element with for (in c code)?
Anonymous
Hello. Say I have 3 files: setup.c, bootloader.c and firmware.c And both the bootloader and firmware call functions from setup. How do we achieve something like this:
Anonymous
#if CONTROL_COMING_FROM_BOOTLOADER #include "bootloader_ui.h" #include "lvgl/lvgl.h" #else #include "firmware/firmware_ui.h" #include "firmware/lvgl_firmware/lvgl.h" #endif
Ilsaf
why output is numbers? string str, str1; getline(cin, str); getline(cin, str1); cout << str[0] + str1[0];
Roshan
Traverse it and use conditions
Anonymous
How to find out how many lines a stdin file that is taken while using a.out file have?
Tostisto
Hello, I am trying to make SPACE SHOOTER game in C with SDL library. I create basic movement. I don't know how create shooter. I don't know how to start making a shooter at all, can anyone advise me how to start? Thanks
klimi
Hello, I am trying to make SPACE SHOOTER game in C with SDL library. I create basic movement. I don't know how create shooter. I don't know how to start making a shooter at all, can anyone advise me how to start? Thanks
this is kinda a vast thing... like i could answer you: you just... write a code that does what you want... But as a general rule: try writing something -> it doesnt work - > make something else, if it doesn't work just a little bit, debug
klimi
Yes, that's a good argument, but for a beginner in SDL it's unrealistic and I need help :D
but you can't give them magical answer how to do stuff... SDL and game development in general is not that easy (at least how i tried it, maybe it wasnt the best idea to start writing my own game engine) i just ... i don't know how to help people if they say: I don't know anything/I don't know what to do/ I am lost if they had some specific problem, eg, how do i make the bullet particle... that is one specific problem.... if they can't even find the peculiar problem, IT field is not a good field for them... at least not as game dev
Sag
printf("\nhi"); printf("\bby"); printf("\rok");
Anonymous
Hi Please answer this question Write a c++ function of compute m! . Call this function in the main program to evaluate the value of the below series 1!+2!+3!+---+n!
Igor🇺🇦
oky output why ?
Check control characters in ASCII https://en.wikipedia.org/wiki/Control_character
Anonymous
data limit?
What ? I don't understand ?
Anonymous
Anonymous
If n=10
then it's simple
Anonymous
just use double for to solve it
Anonymous
Anonymous
Can you solve ?
if u can't think out it I can show demo code
I_Interface
Thanks a lot 😃🤩
Anonymous
Thanks a lot 😃🤩
I think he invented hot keys. Ability to interactively copy and paste was on the unixes before, text was automatically copied by selection and then posted by mouse middle key. Still works in X server