CALVIN
Is it possible to allow the user input a list of numbers in c++....... Without declaring how many numbers are to be on the list.......?
Pavel
Melbgm
Hey guys , array = (int)malloc(sizeof(int) * n); --> The code gives me a warning. What should I do to avoid the warning?
ɛ n h ᴀ n c ɛ ґ 🧟♂️
coal
coal
in any case, aren't you trying to cast it to an int*?
coal
even so, that has several problems
coal
its unnecessary because void * is automatically and safely promoted to any other pointer type
coal
it adds clutter, its redundant and in general bad code
Melbgm
Allright , thank you guys
Melbgm
I have a easy question , The user can enter as many numbers as they want, but there can be a maximum of 5 numbers, how can I limit this in the loop?
\Device\NUL
coal
coal
same in C, you ask for user input as many times as you need
coal
run the for loop for n amount of times until all the input you need was provided
\Device\NUL
coal
\Device\NUL
i like c++
But the performance is different
coal
yeah it is different
coal
but at that level it probably doesnt matter
Melbgm
Lucas
I basically got a udemy course for free, I'm thinking of getting a c++ course focused on developing projects, do you have any recommendation?
coal
in my opinion, optimization should be done when there's an obvious bottleneck and making your code unreadable because it is nanoseconds faster is just nonsense
coal
coal
Melbgm
what is the issue
what I mean is that the user determines how many numbers it will enter beforehand, it can be 3, it can be 5, but it can't be 6, how can I do this?
coal
std::cin returns a truthy value if there's still input available
Melbgm
i cant understand the c++ the std is integer or someth ?
\Device\NUL
coal
the - 1 is included because i assume the value is 1-based
coal
wait, mb
coal
actually wasnt necessary oops
Melbgm
can you write it in c ?
\Device\NUL
nvm
coal
yeah its time complexity is n
coal
because thats the limit of the loop
Melbgm
Okay thanks
CALVIN
coal
CALVIN
use a vector
Please drop here a simple example and how you stored the numbers even....
\Device\NUL
coal
coal
nums.push_back(num)
coal
std::cout << nums[0]
CALVIN
Thanks hey....
donald
can someone help me create a project about the sleeping of the fingerprint module in order to save electricity?
Suka
Harry
/get cbook
Harry
/get cppbookguide
Anonymous
Hello ,
Consider we have following structure
typedef struct{
int *data;
}my_struct;
Now how accsess the value of address data point ?
int a = 0;
my_struct T1;
T1.data = &a;
T1.(*data) = 100;//Syntax error
Pranjal
// Create class "Car" ; Include 2 private data (use getter/ setter)
// Include 2 public data.
// Include necessary method to set and get the data
Pranjal
Can anybody provide some idea to solve this?
klimi
I would start in writing the code
Pranjal
I would start in writing the code
#include <iostream>
using namespace std;
class Car {
public:
string ownername;
string car_color;
int setcarno(string c){
car_no= c;
}
string getcarno(int){
return car_no;
}
char setbrand(string b){
brand= b;
}
string getbrand(char){
return brand;
}
private:
int car_no;
string brand;
};
int main(){
Car car1;
car1.ownername = "Dhiru" ;
cout << "Name of car owner is " << car1.ownername<<endl;
car1.car_color = "black";
cout <<"the colour of car is " << car1.car_color<<endl;
car1.setcar_no("ba1kha2323")
cout <<"the car no is " << car1.setcar_no();
car1.setbrand("pranjal")
cout <<"the car no is " << car1.setbrand();
}
Suka
Pranjal
Thanks
MR
Please guys ,
Am having problem installing Mingw compiler on my PC( am using windows 8 version) I want to add path variable on advance setting but it is not allowing me to insert it
\Device\NUL
\Device\NUL
MR
I use Arch
mito
Max
Which of the 1-2 year students (18-20 years old) wants to try to improve their skills together and try even new things in C \ C ++ during these winter holidays?
In the future, I will be glad to continue to cooperate
Theme options:
Lists (singly linked doubly linked ...)
Trees
Heap
Stack
Graphs
Asymptotic analysis
O big o small
klimi
?
coal
klimi
if you don't provide more information, no on will be even able to help you if they wanted
klimi
\Device\NUL
Well, I compile it wil -Wall and -pedantic-errors and nothing wrong with the program
No warn or Compile Error
Anonymous
\Device\NUL
No
\Device\NUL
Yes
\Device\NUL
I think OS or Compiler doesn't matter as long as the code is following Standard
Nothing
Is there a program that checks the mysql code if it is correct or incorrect?
\Device\NUL
Try to recompile
Anonymous
hi