Nomid Íkorni-Sciurus
Here is the documentation to that
Anonymous
int arr[] = {2,3,5};
//Modifying
for( auto &num: arr)
num = 5;
//Printing
for(auto const &num: arr)
cout << num;
This is someone's code. I'm a little confused at the printing part
He could have just use a normal range base for loop for the printing without referencing but he didn't? What's the benefit of using reference and const over using general for range based for to print the nums
\Device\NUL
\Device\NUL
With const part we can sure that the value wouldn't change
Eric Czeladka 🇫🇷
Hi,
New in C
I am trying to write
"Il y a 15% de reussite"
I have :
printf ("il y a %d de reussite. \n",res);
But i don't know how to put the % symbol without having warnings and bad results. I searched on the web but you only find HOW tu use % 🤣 but not how to neutralise it...
Any help ? Tks
Khadija
Hi please I have a question : why we choose the highest time complexity ?
For example if we have : n+n^2 = why we choose o(n^2 ) ?
✨ I need to understand the reason please 😔 thank you
Talula
Eric Czeladka 🇫🇷
Int
Talula
Int
Then you shouldn't get any warnings for this... if it is possible put the whole code.
Eric Czeladka 🇫🇷
int main()
{
// préparation de variables : déclaration et initialisation
int x,note,pct,res;
x=0;
note = 0;
pct=0;
res=0;
fflush(stdin);
printf ("Veuillez saisir 10 notes suivies de Enter a chaque fois \n");
for (x=1; x<11; x=x+1)
{
scanf("%d",&note);
if (note>10)
{
pct=pct+1;
}
}
res=(pct*100/10);
printf ("il y a %d pct de notes superieures a 10. \n",res);
return 0;
}
Eric Czeladka 🇫🇷
il y a 15 pct de notes...
Eric Czeladka 🇫🇷
il y a 15% de notes... i dlike to escape the %
Eric Czeladka 🇫🇷
Found it...
Eric Czeladka 🇫🇷
printf ("il y a %d %% de notes superieures a 10. \n",res);
Talula
Oh you wanted to print %? God!!!
Talula
😂 Couldn't understand, sorry.
Eric Czeladka 🇫🇷
printf is special... can't escape with\
Eric Czeladka 🇫🇷
tks anymay your question made me have another idea
Eric Czeladka 🇫🇷
with printf we have to double % to have one :-)
anubhav
how we can make a alexa sir type programme through c++
anubhav
*siri
Vladimir
Here you are connoisseurs of the C language, the so-called sishniks, tell me or answer this question is it worth it for a low-level specialist to learn the Fort programming language🤗
Vladimir
I see my question was difficult for you!🤭
hello
Does anyone know how you can use variables and files from file pointers from one c file in another c file?
Pavel
Anonymous
Does obfuscating code help me to avoid plagiarism? I mean if we need the same output, but a different code. So, can I avoid plagiarism with obfuscating? Thank you in advance.
hello
http://pastie.org/p/2nPUaVHQKinbM7bC8aptYN
hello
in this code "c" is a variable i put a value to in another file and code is a name of a file pointer i made in a different c file
Anonymous
Ok. Thank you
Anonymous
Pls who knows how to create a telegram bot
n
php
Anupam2.7
klimi
why not c or c++?
because of libraries?
well... you will have to deal with low level stuff, if you are fine what then you can use even assembler or what not... but you will spend more time thinking about the programming language rather than what you want to program
Anupam2.7
#
Anyone help me
#
Why my code not running and show like this in vs code
#
Klimi ding dong leni hai
klimi
Anonymous
Hey
Anonymous
dont ask to ask
Fatih
What do you need?
Dm
Please check rules and use pastebin or whatever
And please highlight what exactly wrong (compilation? Different behaviour?)
Null
why is dark>?
Anonymous
Is there a way we share our small program to someone and not as an output but as a program (like an apk)?
klimi
Anonymous
Anonymous
I want to share the program like if my program is ex -
Enter number : 2
Enter number again : 2
And then it scans and give the answer 4
Anonymous
So that they can see our program
Pavel
Pavel
Just build it with release settings (depends on how you build it)
Anonymous
Anonymous
Are you trying to say that save your code in a file and then rename file to .apk or .exe?
Pavel
Are you trying to say that save your code in a file and then rename file to .apk or .exe?
No, when you run your code, what usually happens is that the compiler and linker build an executable, save it somewhere and run it.
You just need either to find where it built to and copy it, or make it build to the location you want.
How, depends on what IDE you use. If you use online IDE for example you can't do that, because the executable is stored on the server side.
Anonymous
Pavel
Ohh no
You need to install a compiler to your machine, if you don't have it
Anonymous
Pavel
Just copy your code to a file, name it something like yourprogram.cpp and run the command that TheAcelot mentioned above (assuming your compiler is mingw)
M
Hello guys
I want to Find the minimum number of coins that make a given value
Using (dynamic programming with memoization)
Here is the code 👇🏻 in a bottom-up manner.
Who can help me writing the code in a top-down manner (memoization)🥲?
Deepak Chaurasia
Hello guys i was writing some codes and i am bit confused how 1%10 equal to 1 isn't its should 0
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi, I'm reading stuff from a file using fgets:
while(fgets(buff, sizeof(buff), fp)){
fprintf(stdout, "this is buff %s and this is lenght %ld\n", buff, strlen(line));
// Remove the \n at the end:
buff[strlen(buff) - 1])= 0;
fprintf(stdout, "This is buff without new_line: %s and this is lenght: %ld\n", buff, strlen(line));
}
So this is the problem. I know the string he reads is 10 char long (there's no doubt about it). Since strlen does not count NULL terminating carachter, I expected, at first print, lenght= 11, instead it prints lenght= 12.
After I remove the \n, the lenght is 11.
But now I'm confused, as I don't understand what the last carachter is. If it's not \0 and not \n, since I got rid of it, what is it? Could you please help? Thanks!
Inside the file I've got written: 1a2b3c4e5d
And in another file I've got written the same thing:
const char *ESCAPE= "1a2b3c4e5d";
The endgoal would be to do if(strcmp(buff, ESCAPE)==0), but it's never true, as ESCAPE has lenght 10 and there's something more in buff that makes its lenght 11
Pavel
Hi, I'm reading stuff from a file using fgets:
while(fgets(buff, sizeof(buff), fp)){
fprintf(stdout, "this is buff %s and this is lenght %ld\n", buff, strlen(line));
// Remove the \n at the end:
buff[strlen(buff) - 1])= 0;
fprintf(stdout, "This is buff without new_line: %s and this is lenght: %ld\n", buff, strlen(line));
}
So this is the problem. I know the string he reads is 10 char long (there's no doubt about it). Since strlen does not count NULL terminating carachter, I expected, at first print, lenght= 11, instead it prints lenght= 12.
After I remove the \n, the lenght is 11.
But now I'm confused, as I don't understand what the last carachter is. If it's not \0 and not \n, since I got rid of it, what is it? Could you please help? Thanks!
Inside the file I've got written: 1a2b3c4e5d
And in another file I've got written the same thing:
const char *ESCAPE= "1a2b3c4e5d";
The endgoal would be to do if(strcmp(buff, ESCAPE)==0), but it's never true, as ESCAPE has lenght 10 and there's something more in buff that makes its lenght 11
Maybe there's '\r' symbol at the end of the string, or something that your editor added. You can find some hex editor application to investigate your file byte-by-byte
https://softwareengineering.stackexchange.com/questions/29075/difference-between-n-and-r-n
Anonymous
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Yes, it was the \r. Thank you very much!
Pavel
You can use types for templates, but it depends on what you're trying to achieve with it.
#
How to learn faster c
#
Any YouTube channle ya websites
Dm
Does someone know how to compile qr quick app on windows for Linux (Ubuntu)?
Pavel
Is it guaranteed that capacity() of a vector will be equal to the value passed to reserve() when reserve called on a freshly created empty vector?
Eric Czeladka 🇫🇷
Tks i managed to find it by myself... Printf is another matter to escape %
Eric Czeladka 🇫🇷
Tks anyway.
Eric Czeladka 🇫🇷
Tks anyway, it will help me next time to search questions in Google.
Anonymous
Anonymous
You can create a struct like this:
template <typename T>
struct ClassType{
using Type = T;
};
and use it to encapsulate typenames.
emiteclap
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi, is it possible to create your own signals in C?
Like, usually you write
signal(SIGINT, SIGINT_HANDLER)
so whenever the user presses CTRL+C the actual routine will pass the control to a subroutine which is the handler that will do stuff before returning the control to the upper routine.
I need to do something like, but I need to create my own signal. Like, when the user presses CTRL+SHIFT+R, the signal function shall recognize this as a signal and therefore call a handler. Is it possible to do so?
Anonymous