SK
Hello, What does multiple scope operator (::) in a line means.?
You know me
Hello, What does multiple scope operator (::) in a line means.?
Nested namespaces or maybe some member of a class inside a namespace etc
klimi
I guess he meant help with "exam"
Nah, people wouldn't ask for that
Simo
hi everyone
Simo
?
Simo
I am 17 years old and I come from Italy, I do IT at school and I was trying to do an exercise that was assigned to me but I got stuck in one point
Pavel
I am 17 years old and I come from Italy, I do IT at school and I was trying to do an exercise that was assigned to me but I got stuck in one point
If you can explain what specifically you don't understand and preferably show your code (if relevant), then we may be able to help you. Just note that we won't do your assignment for you.
Simo
don't worry I know, I would just like a hand with the syntax, if you do it for me then I will not learn anything
Simo
You want to memorize the score (0 = defeat, 1 = draw, 3 = winner) obtained by each single team Serie A football (20 teams), for each matchday of the championship (38 days). Also store even the names of the teams. To make it easier to randomly load data, use the value 2 for winner. Write a C / C ++ program that: 1. Stores the data 2. View the uploaded data for each day 3. Calculate, for each team, the number of games lost, drawn and won. 4. Calculate, for each team, the total score obtained at the end of the championship.
Simo
I'm stuck in point number 3. with syntax
Simo
do i have to send the code?
Anonymous
do i have to send the code?
Go to listen the teacher for make this little script
Simo
it's a task, if I knew how to do it I didn't ask for help
Ludovic 'Archivist'
it's a task, if I knew how to do it I didn't ask for help
Always send all the info you have. If it is homework, my advice is to explicitly state so and provide what you have done and what you have tried. People will NOT help you if you ask them to do the homework for you. They will however give you pointer as to what to search for or where to find the info
Simo
but i'm not asking to do it, the boy said i just had to listen to the teacher, but it seems obvious to me that if i knew how to do it i wouldn't ask for help
Ludovic 'Archivist'
but i'm not asking to do it, the boy said i just had to listen to the teacher, but it seems obvious to me that if i knew how to do it i wouldn't ask for help
Which is why I answered you so. I additionally advise you to follow this when publishing code: https://archivist.nekoit.xyz/readable-code-a-guide-to-absolute-beginners/
Divyanshi
What might be the problem in my code if redefinition of 'int main()' error is coming??
Pavel
What might be the problem in my code if redefinition of 'int main()' error is coming??
You can have main function defined only once in your program, because of that you can't define it in a header (maybe you can with inline keyword though). Also you should never include *.cpp files, that also can be a reason. (there's an exception with unity builds when you actually include cpp files, but that is special situation)
artemetra 🇺🇦
i saw a piece of code that did this #if 1 some code here #endif what is it for? won't the code always be executed?
You know me
i saw a piece of code that did this #if 1 some code here #endif what is it for? won't the code always be executed?
These are preprocessor directives to conditionally compile the code that we want. For example, if you want to use func1 when linux and func2 when windows.
Pavel
Is there a list of standard modules? Or even better, list of standard modules mapped to includes?
artemetra 🇺🇦
These are preprocessor directives to conditionally compile the code that we want. For example, if you want to use func1 when linux and func2 when windows.
yes, but 1 is always true so the code will always be included. what's the point of using #if 1 here?
Puspam
Is there a list of standard modules? Or even better, list of standard modules mapped to includes?
There's no such thing as "standard". Different libraries have different purpose. Suppose you are a mathematics software programmer. You obviously would not need libraries which deal with web technologies.
Pavel
the best for everyone
Share the code
// // Created by hassa on 01/10/2022. // #include <stdio.h> #include <stdlib.h> #include <conio.h> #define size 5 int stack[size]; int top=-1; int data; void push(); void pop(); void peek(); void display(); void push(){ printf("Enter the data that you want "); scanf("%d",&data); if(top==size-1) printf("the stack has been overflow"); else{ top++; stack[top]=size; // pay attention // until be full // it needs to understand much better } } void pop(){ int item; if(top==-1) printf("underflow"); else{ item= stack[top]; // pay attention // and if you dont want to write the pop item there is no need to write this line top--; printf("%d",item); } } void peek(){ // top if(top == -1) printf("the stack is empty"); else printf("the top is %d",stack[top]); } void display(){ for (int i=top ; i>=0 ; i--) { printf("the value of the stack << is %d",stack[i]); } } int main() { int choice=1; int d; do { printf("1- to push it\n"); printf("2- to pup them\n"); printf("3- to show the last top\n"); printf("4- to display them \n"); printf(" pressed 0 to get out \n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: push(); // printf("\nEnter A value:"); // scanf("%d",&d); break; case 2: pop(); break; case 3: peek(); break; case 4: display(); break; default: printf("wrong choice\n"); } } while (choice !=0);// it will get out if we pressed 0 getch(); }
the best for everyone
can anyone tell me what is the problem in this code
the best for everyone
it doesn't give me any errors but its not working as it should have been
klimi
// // Created by hassa on 01/10/2022. // #include <stdio.h> #include <stdlib.h> #include <conio.h> #define size 5 int stack[size]; int top=-1; int data; void push(); void pop(); void peek(); void display(); void push(){ printf("Enter the data that you want "); scanf("%d",&data); if(top==size-1) printf("the stack has been overflow"); else{ top++; stack[top]=size; // pay attention // until be full // it needs to understand much better } } void pop(){ int item; if(top==-1) printf("underflow"); else{ item= stack[top]; // pay attention // and if you dont want to write the pop item there is no need to write this line top--; printf("%d",item); } } void peek(){ // top if(top == -1) printf("the stack is empty"); else printf("the top is %d",stack[top]); } void display(){ for (int i=top ; i>=0 ; i--) { printf("the value of the stack << is %d",stack[i]); } } int main() { int choice=1; int d; do { printf("1- to push it\n"); printf("2- to pup them\n"); printf("3- to show the last top\n"); printf("4- to display them \n"); printf(" pressed 0 to get out \n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: push(); // printf("\nEnter A value:"); // scanf("%d",&d); break; case 2: pop(); break; case 3: peek(); break; case 4: display(); break; default: printf("wrong choice\n"); } } while (choice !=0);// it will get out if we pressed 0 getch(); }
#paste
You know me
yes, but 1 is always true so the code will always be included. what's the point of using #if 1 here?
It is generally used for debudding or enabling/disabling some code. Not a standard practice though.
Pavel
Do you know any online compilers that support modules? I tried to enable/use them on wandbox using gcc and clang but without luck: https://wandbox.org/permlink/dRxtXqPMcMPip8gW
²
check it
Pavel
check it
Doesn't seem to work, even if choosing "gcc (modules)" https://godbolt.org/z/5xTGGTb3Y Maybe my code is not correct, I used code from examples but I can't find what modules are even available in STL, maybe syntax or naming conventions were changed from the proposal to the actual implementation
Pavel
Tried to use import <iostream>; as in the first example here, with no luck also: https://en.cppreference.com/w/cpp/language/modules
Anonymous
Few days ago I started learning C language, I'm a beginner in this Coding field, So is there any good app or tutorial??
Nomid Íkorni-Sciurus
Guys, am I doing something wrong here? (0xFF << 24 | 0xFF << 16 | 0xFF << 8 | 0xFF) == 0xFFFFFFFFF it returns false for me and I don't understand why
Nomid Íkorni-Sciurus
uh? let me check
Nomid Íkorni-Sciurus
lol
Daulet
lol
Is it reason of your problem?
Nomid Íkorni-Sciurus
Is it reason of your problem?
part of it the C code works, but NodeJS seems to interpret 0xFFFFFFFF as -1 even though it's in a UInt32 context
Nomid Íkorni-Sciurus
Is problem solved?
the C part, yeah!
Daulet
the C part, yeah!
Send plz js code here
Anonymous
Nomid Íkorni-Sciurus
Send plz js code here
I just removed the exceeding F
Daulet
I just removed the exceeding F
But code not work correctly?
Nomid Íkorni-Sciurus
But code not work correctly?
it works from the C side now there is something wrong with my NodeJS part
Daulet
it works from the C side now there is something wrong with my NodeJS part
All numbers in js is float64, problem comes from this
Nomid Íkorni-Sciurus
All numbers in js is float64, problem comes from this
the main problem is the two's complement
Nomid Íkorni-Sciurus
I found a solution by the way.
Daulet
I found a solution by the way.
Why just use ffi? As I know nodejs have native C/C++ interface
Daulet
because it's wasm
you can call wasm from js then
Nomid Íkorni-Sciurus
you can call wasm from js then
YES but nodejs integers are always in two's complement there is no "unsigned" integer thing in js
Nomid Íkorni-Sciurus
How you fixed that problem then?
by shifting integers left by 32 and then removing the sign bit
Anonymous
is vs good for c++ or vsc is better? any opinion?
Daulet
is vs good for c++ or vsc is better? any opinion?
What vs? VS Code or Visual Studio
Anonymous
for vs i mean visual studio
Daulet
for vs i mean visual studio
Visual Studio good if you use windows
Anonymous
ok so i'll choose that one
Anonymous
thankss
Prithvi
Hi . I've written 2 classes in single cpp file. One class is in upper and other class is writes down to it..... I can't access the class that was written in downthere by obj in upper class.... is says....undefined class.... i'm new to c++ .. someone please help me....
Anonymous
how to use lookbehind in regex?
Anonymous
the program throws std::regex_error what() invalid special open parenthesis
Ольга
https://onlinegdb.com/KGu04aPno How to make the maxword function return exactly the word that is the maximum??? I will be very grateful for any help or advice
Ольга
https://onlinegdb.com/KGu04aPno How to make the maxword function return exactly the word that is the maximum??? I will be very grateful for any help or advice
Now it finds the length, and I would like it to also find the word itself. I really not understand how to do it
Ольга
Use c++ strings
https://onlinegdb.com/uYLsMCjYe I tried to do it here. But it does not want to print that element (line 29 is a segmentation error and I don't know how to fix it)
Ольга
https://onlinegdb.com/Co_7gjr21 go through this updated code
I'm sorry, but I don't see what has changed here?