Евгений
Ludovic 'Archivist'
How told you that I said C has a garbage collector?
You didn't, you just gave me the idea
Ludovic 'Archivist'
If you do not mind me asking, where do you teach?
In a few schools in france and online
Danya🔥
In a few schools in france and online
By schools you mean high schools or universities/colleges?
Ludovic 'Archivist'
\Device\NUL
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys, I wanted to ask you about the free() function when operating with buffers. So, I know that we use free when dealing with dangling pointers and stuff like this, but I do not understand if it is needed with strings. For istance: char buff[1024]; The code does its stuff (filling the buffer with strings and so on) Now I don't need the buff anymore, thus the question: what do I do with it? I am tempted to use the free function as it follows: free(buff); Is it right? Or is it a mistake?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Wrong, stack allocated memory can't be freed until the program ends
Thank you very much, so this needs to be done only if I assign the string in the heap, right?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
thank you!
Ashraf
Hello,everyone. I have a question from C. I want to input integers like that: 3 1 2 2 3 3 4 The first line is a test case.The next ones are values,but i don't know how to write that one
Faramarz
Hello,everyone. I have a question from C. I want to input integers like that: 3 1 2 2 3 3 4 The first line is a test case.The next ones are values,but i don't know how to write that one
int main() { int n; printf("Enter a number: "); scanf("%d", &n); for(int i = 0; i < n; ++i) { for(int j = 1; j < 3; ++j) printf("%d ", i+j); printf("\n"); } return 0; } I'm not sure if this is what you meant!
Lakshya
Hello ! I'm Technical Recruiter at TechCurators. We are an assessment based company. We need interns for *coding project* *Details:* 30 ques 1 month Stipend 7500 Lor certificate Questions in language C+++ Test cases If you are interested, kindly revert back with your contact details.
Danya🔥
INR
That's unfortunate
Danya🔥
I'd join you for 7500$ per assignment
Mahad
Hello Everyone
Mahad
Can Anyone Help In C program
Mahad
HOW to repeat A Program Using Do While loop
Anonymous
What will be the logic of neither max nor min with c programming
Mahabub Alam
HOW to repeat A Program Using Do While loop
do { statement(s); } while( condition );
Mahabub Alam
do { statement(s); } while( condition );
Mahad Use repeating conditions on while. It will repeat.
Hima
for(int i=1;i<n;i++) { auto it=mp.lower_bound((arr[i]+arr[i-1])/2); mp.erase(it); } why the keys from the map are not being deleted?
Emmanuel
Method and namespace ?
These are C++ metrics.. I'm yet to start learning it.. 👍👍
Pavel
These are C++ metrics.. I'm yet to start learning it.. 👍👍
dot is used to reference a function or variable of a class using an object of that class (or reference to it). Class object; object.function(); :: is used to resolve scopes (e.g. namespaces, reference static variables/functions of a class, etc.) https://stackoverflow.com/questions/15649580/using-scope-resolution-operator-in-c
Anonymous
Actually no. Think like that,I input the integer 3,then I also want to input the others,like arrays
Implementing the above program with Newline and simple addition using while loop?
Ashraf
Can you show me the way?
Anonymous
Can you show me the way?
Would it be fine If it is in Java ?
Dima
Hmmm need more posers
Danya🔥
Can you show me the way?
No one is going to solve anything for you
Anonymous
Would it be fine If it is in Java ?
The logic would be same...just syntax will be different
Anonymous
Kevin
Does anyone do competitive coding here on Codeforces?
Anonymous
Naol D
Hello there everyone. i have a question in C. I defined a struct which is typedef but how can i include the struct inside itself ? // example typedef struct { prop1 p1; prop2 p2; // here i want to include this // struct as a pointer... // but how ? // object *ptr; }object;
Pavel
which means i have to write the name first right ?
Yes, probably you can do struct object; and then do what you did, not sure, not very familiar with this C syntax
Ivan
why this doesn't works? https://www.online-ide.com/x8BG6yDPwe
Anonymous
why this doesn't works? https://www.online-ide.com/x8BG6yDPwe
this is working for me i am able to a run a program, but I don't see the input screen actually, output screen is good.
Ivan
Why? It won’t let me enter a complete name with spaces in option 1?
Anonymous
not getting you
\Device\NUL
std::cin doesn't ignore newline or EOF, it will remains on input stream
KBS
void SecureBuffer(const char *arg) { } int main(int argc, char *argv[]) { if(argc < 2) return -1; SecureBuffer(argv[1]); return 0; } Complete the function SecureBuffer to ensure that an array of [10] can not be overflown via a Buffer overflow attack? 
X
You can buffer the memory when you reach the top of the max
KBS
void SecureBuffer(const char *arg) { } int main(int argc, char *argv[]) { if(argc < 2) return -1; SecureBuffer(argv[1]); return 0; } Complete the function SecureBuffer to ensure that an array of [10] can not be overflown via a Buffer overflow attack? 
void SecureBuffer(const char *arg) { char values[9]; strcpy(const, values); fprint(values); } int main(int argc, char *argv[]) { if(argc < 2) return -1; SecureBuffer(argv[1]); return 0; } Hope I'm correct?
\Device\NUL
And don't use fprintf family with blindly passed it into parameter. printf(str) This could lead to security holes if str contain % char. printf("%s", str) should be okay
KBS
#include<iostream> using namespace std; int main() { char buf[12]; cin.width(12); cin>>buf; cout<<"Contents in the buffer are"<<buf<<endl; return 0; }   In the program above, discuss the function of line 6 and what function does it do in terms of security. Your answer: 🙏🙏🙏🙏🙏🙏
\Device\NUL
Now i Feel bad after answering your question before
KBS
You didn't answer my question directly bro, you only corrected it
Anonymous
It's to avoid buffer overflow
😁Hello guys i need help, i have the following exercise: 1- Ask the user to enter ten numeric values and sort these in ascending order. values, storing them in a vector. Order the value as it is entered. show the final on the screen the values in order. My code sorts after reading, but it asks to sort as values are read, how do i do it? ----------------------------begin of My code--------------------------- #include <iostream> #include <array> int main(){ std::array<int,10>v{}; //input values for(int i = 0;i < v.size();i++){ std::cout<<"value-> "; std::cin>>v.at(i); } // sorted array int j{}; std::cout<<"Array sorted->"; while(j < v.size()){ for(int k = j+1; k < v.size();k++){ if(v.at(j) > v.at(k)){ int exchange{}; exchange = v.at(j); v.at(j) = v.at(k); v.at(k) = exchange; } } // output array std::cout<<" "<<v.at(j); j++; } return 0; } ------------end code---------------------------------------------
Anonymous
😁Hello guys i need help, i have the following exercise: 1- Ask the user to enter ten numeric values and sort these in ascending order. values, storing them in a vector. Order the value as it is entered. show the final on the screen the values in order. My code sorts after reading, but it asks to sort as values are read, how do i do it? ----------------------------begin of My code--------------------------- #include <iostream> #include <array> int main(){ std::array<int,10>v{}; //input values for(int i = 0;i < v.size();i++){ std::cout<<"value-> "; std::cin>>v.at(i); } // sorted array int j{}; std::cout<<"Array sorted->"; while(j < v.size()){ for(int k = j+1; k < v.size();k++){ if(v.at(j) > v.at(k)){ int exchange{}; exchange = v.at(j); v.at(j) = v.at(k); v.at(k) = exchange; } } // output array std::cout<<" "<<v.at(j); j++; } return 0; } ------------end code---------------------------------------------
Johnson
/get cbook
Anonymous
Anybody with knowledge about multithreading in c++