Ammar
fflush(stdin) is UB in C
Ditto that. Yes, fflush(stdin) is UB. If it's implementation defined at all, it won't be portable. Ref: https://stackoverflow.com/questions/2979209/using-fflushstdin
Anonymous
Thanks
Anonymous
If anyone could suggest me some C++ project ideas using classes n objects, it would be sweet.
Nomid Íkorni-Sciurus
Hello
Nomid Íkorni-Sciurus
Window() = default; Window(const Window&) = delete; virtual ~Window() = default; virtual void init(HINSTANCE hInst, HWND parent) { _hInst = hInst; _hParent = parent; }
Nomid Íkorni-Sciurus
I was looking at this piece of code in the source of Notepad++ (Window.h) and I was wondering... why to declare the constructor default and then to declare a init() ?
\Device\NUL
👁👄👁
Ammar
Maybe something goes wrong with your code.
Ammar
OK
Anonymous
Define a class named BUBBLE consisting of following members: i) ROLL: of type unsigned short integer under private visibility label ii) NAME: a character array of size 30 under private visibility label iii) PERCENT: of type float under private visibility label iv) getdata(): a public member function which accepts all data members. v) putdata(): a public member function which displays all data members. vi) check(): a public member function which accepts an object of type BUBBLE and returns 1 and 0 depending on comparison of data member NAME of the two objects. Write main function which accepts an array of object from the user and performs BUBBLE SORT on basis of data member NAME, to obtain the array in alphabetical order.
Anonymous
Define a class named BUBBLE consisting of following members: i) ROLL: of type unsigned short integer under private visibility label ii) NAME: a character array of size 30 under private visibility label iii) PERCENT: of type float under private visibility label iv) getdata(): a public member function which accepts all data members. v) putdata(): a public member function which displays all data members. vi) check(): a public member function which accepts an object of type BUBBLE and returns 1 and 0 depending on comparison of data member NAME of the two objects. Write main function which accepts an array of object from the user and performs BUBBLE SORT on basis of data member NAME, to obtain the array in alphabetical order.
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; class bubble { unsigned short int roll; char name[30]; float percent; public: void getdata() { cout<<"Enter roll no, name, percent"<<endl; cin>>roll>>name>>percent; } void putdata() { cout<<"Roll no: "<<roll<<endl; cout<<"Name: "<<name<<endl; cout<<"Percent: "<<endl; } int check(char *n[30]) { if(strcmp(name,*n)==0) return 0; else return 1; } }; int main() { int n,i,j; char nomen[30]; bubble b[100],x; cout<<"Enter size of array"<<endl; cin>>n; cout<<"Fill array"<<endl; for(i=0;i<n;i++) b[i].getdata(); for(i=0;i<n-1;i++) { for(j=0;j<n-i-1;j++) { } } cout<<"Sorted list in alphabetical order"<<endl; for(i=0;i<n;i++) b[i].putdata(); return 0; }
Anonymous
Can anyone help me with that ^
Nomid Íkorni-Sciurus
init is not the part of the classes that are being used by Windows to initialize the windows Application.
and so? I mean, init() is like a constructor if I delete init and put the code into the constructor they would work the same way
Talula
and so? I mean, init() is like a constructor if I delete init and put the code into the constructor they would work the same way
I would, but I don't know what it's called but the the previous init() is called to (I forgot the term), so basically you'll have to call init() anyways...
Nomid Íkorni-Sciurus
that would be weird though, because super constructors would be called anyways instead he declared it "virtual" so I'm guessing they're considering to customize the initializer which is the part I fail to understand
Nomid Íkorni-Sciurus
why not to use the constructor?
Talula
why not to use the constructor?
Well frankly speaking I programmed Windows in C++ back when I was in school, that is like 16 years ago... but I remember using init() as it had to be used, but I never question it.
Phoenix
Hey guys i m a beginner here so bare with me if i ask some silly questions
Phoenix
My question is Does main function always have to be declared with int data type?
Nomid Íkorni-Sciurus
you could make it void if your compiler allows it
\Device\NUL
you could make it void if your compiler allows it
But that's wont compile with -pedantic-errors flags
Nomid Íkorni-Sciurus
but honestly it's better to make main return an error code.
Anshul
My question is Does main function always have to be declared with int data type?
I think now you can't but in some c compiler it allows to write you void main
Anonymous
I wanna ask u like can we assign an operator to a variable?
\Device\NUL
I got warned when using void main
Phoenix
Yeah that's the point i watched some c++ lectures that were old and they went using void main But today my compiler is giving an error so i just had a query why.
\Device\NUL
The value returned by main function is the value returned to the OS, cmiiw
\Device\NUL
You can see returned program value with echo $? in *nix, cmiiw
Anonymous
My question is Does main function always have to be declared with int data type?
Depends on what type of software u sing for programming
Nomid Íkorni-Sciurus
The value returned by main function is the value returned to the OS, cmiiw
it is just a value the OS does almost nothing with it if not returning it from exec/execve stuff
Phoenix
IDE
Phoenix
So is this group good for asking doubts if any ? I m a beginner though
Anonymous
Hello, Anyone have C4droid??
Phoenix
I have Cxxdroid apk through which you can code in your mobile phone.
Anonymous
hi
Veykhan
I have Cxxdroid apk through which you can code in your mobile phone.
I use both. But Cxxdroid doesn't have a integrated debugger.
Anshul
hi
Hello
Anonymous
folks, what does 'n' mean in "strncpy()"?
Anonymous
n in strncpy()?
Anonymous
Anonymous
string copy it's just a short form ig
Roy
Hey guys, quick question. What is the function to exit the whole C++ program? Like if someone entered a certain value, it leads for the program to end. What is that function that does that?
Anshul
It's Strcpy
Anshul
I never heard strncpy
Roy
How?
Anshul
Just use throw;
Anshul
It'll call terminate as no catch block written
Daniela
Hi, can anybody help me ?
Golden Age Of
Hi, can anybody help me ?
https://www.quora.com/What-is-a-meta-question
Anonymous
string copy it's just a short form ig
I think the middle 'n' means "number"
Anonymous
I never heard strncpy
it does exist..
CALVIN
I never heard strncpy
It for copying string characters to another variables
Anonymous
https://en.cppreference.com/w/cpp/string/byte/strcpy
CALVIN
And what's strcpy
It's a string function for copying string characters.... I guess you confuse these with strcmp
Anshul
strcpy( ) function copies whole content of one string into another string. Whereas, strncpy( ) function copies portion of contents of one string into another string.
Anshul
Found this*
{ЅᎯⅅⅅ-ℰ}
Hello everyone, I'm struggling with arduino 🤭 you can also output this with While loop: 1 22 333 4444 55555....
Ssssss
hello guys...i m stuck at this error error: redefinition of 'BankDeposit::BankDeposit()' 22 | BankDeposit::BankDeposit()
Ssssss
redefinition of class error.
{ЅᎯⅅⅅ-ℰ}
So what's the problem ?
But this one with a while loop. I can't do that.🙈 Is it even possible to do that with a While Loop?👇
{ЅᎯⅅⅅ-ℰ}
void setup() { Serial.begin(9600); } void loop() { for ( int i = 9; i > 0; i--) { for ( int a = 0; a < i; a++) { Serial.print(i); delay(200); } Serial.println(" "); } for ( int b = 2; b < 9; b++) { for ( int c = 0; c < b; c++) { Serial.print(b); delay(200); } Serial.println(" "); } }