ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
I’m trying write a program to only accept 10 digits from a user in c++
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
If anyone can help with i’d be glad I’m new to this Thanks!
Hamidullo 🇺🇿
github.com/A404M/SL A simple compiler and VM
Great. Where did you learn these things? Give me route
YUSUF
Do any one know neural network with c++
'''''''
https://hastebin.com/obujimaxeq.cpp, it says segmentation fault at line 68 in display function? Where did I go wrong?
'''''''
what's your input?
first 2 then 1, then display
'''''''
Captain
highest doesn't return anything You should just call the function instead of printf
Captain
Np
Anonymous
Hi all,I am new to c++
Anonymous
how could I create another main in the file at the same time
Anonymous
I have very small assignment on c++,I want to share media so whom could I write in pm.just need some help
Prince Of Persia
Great. Where did you learn these things? Give me route
Actually no where (just google till now)
Ster-Devs
how could I create another main in the file at the same time
It's not possible to create two main function in C++, morever in the same file i think... Maybe you should try looking for multitreading...
Prince Of Persia
Anonymous
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Just check the length if it's all at once.
Don’t really get you bro But what I’ve currently done is declared a string variable (called input) that should hold the user input and also declared an int Variable called “Maxchar”and assigned 10 to to it. Then the code reads if (input.size() > Maxchar || input.size < Maxchar) {cout <<“Error”;}
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Anonymous
Yes bro
Oh, so that's a good way to do it^ if using std::cin.
Prince Of Persia
why switch statement is faster than array of function pointers in both optimized and non-optimized codes?
Anonymous
why switch statement is faster than array of function pointers in both optimized and non-optimized codes?
https://stackoverflow.com/questions/4442835/what-is-the-runtime-complexity-of-a-switch-statement If I undestood, array have linear complexity, but as you see in this article, switch isn't
Anonymous
https://stackoverflow.com/questions/4442835/what-is-the-runtime-complexity-of-a-switch-statement If I undestood, array have linear complexity, but as you see in this article, switch isn't
Think of switch statements as a map lookup. In both optimized and non optimized code, modern compilers often translate switch statements into lookup tables (also called jump tables) and the matching switch case is accessed directly. That is why teaching kids that switch statement is equivalent to an if-else if-else block is wrong. An if-else if-else conditional block will often be slower than a switch statement because of branching with processors often indulging in rollbacks. There are clever things that a compiler and a modern processor can do here as well but it can at best match a switch statement's efficiency and will most of the times be slower.
Anonymous
Yes, you are right)
Prince Of Persia
Yes, you are right)
Except the kids word😅 Should be beginners
Ибраги́м
https://www.youtube.com/watch?v=Yop9D3V2KBk
Manu
Does anyone know ..where should i learn about functions ?
Abhishek
Does anyone know ..where should i learn about functions ?
YouTube (try channels like The Cherno) After that try to build very simple and small programs with it
Kartik
I'm trying to split a string (at whitespace) into 2 parts and storing them in 2 different variables (N and F in my case) Eg Input: abdhfurjs qweyd Expected output: part1: abdhfurjs part2: qweyd //T is total number of strings to enter and split. Can be ignored! int main(){ int T; string str; string N, F; int endindex; char space=' '; //string N = ' ',F = ' '; cin>>T; for (int i = 0; i < T; i++){ getline(cin, str); } int z = str.length(); for(int i=0; i < z; i ++){ if(str[i]==space){ endindex=i; } } N=str.substr(0, endindex); cout<<"part1: "<<N<<endl; //GOING GOOD F=str.substr(endindex+1, z-endindex-1); cout<<"part2: "<<F<<endl;. //GOING GOOD return 0; }
Kartik
It's working. But is there any better solution/alternative solution to this??
Anonymous
It's working. But is there any better solution/alternative solution to this??
Yes. 1. Use find* methods available in the string class Or 2. Use a stringstream
Kartik
I know 1st one...will try. Can you explain about 2nd one?
Kartik
Stringstream
Anonymous
Stringstream
https://en.cppreference.com/w/cpp/io/basic_stringstream
Manu
📖
I don't have anyone either my clg not start yet ....
Abhishek
Cherno ? Right
Yes one example... There are more like Darek Banas, One Lone Coder... etc...
Abhishek
Kartik
Btw your program logic is wrong.
I'll test it again and will try to correct it. Thanks for the link!
Ayomide
Hello everyone, am a beginner programmer learning C++ and C, I want to ask a question please, if I want to create an app the browses, is it a command code in the program that connects the app to the internet? If yes how? and if no how do I do it to connect the app to the internet. I already searched Google but I am just getting redirected to another topic, Thanks for your answers.
Manu
J.
Hello
Prince kumar
#include<stdio.h> #include<malloc.h> #include<stdlib.h> typedef struct{ struct tree *right; int info; struct tree *left; }tree_type; int num; tree_type *root=NULL,*temp; char opt; do{ printf("enter the elements\n"); scanf("%d",&num); temp=create(num); if(root==NULL) root=temp; else insert(root,temp); printf("for continue y/n"); scanf("\t%c",&opt); { while(Opt=='y'); printf("the inorder transversal of the tree is ........\n"); } tree_type *create(int num) { tree_type *temp; temp=(tree_type*)malloc(size of (tree_type)); if(temp==NULL) printf("not enough memory"); else { temp->info=num; temp->left=NULL; temp->right=NULL; } return temp; } void insert(tree_type *root,tree_type *temp) { if(temp->info<root->info) { if(root->left=NULL); root->left=temp; else insert(root->left,temp); { else if(root->right=NULL) root->right=temp; else insert(root->right,temp); } } } }
Prince kumar
Error in do
Prince kumar
Check it
Captain
Error in do
What's the error
Prince kumar
In do
Avinash
Error in do
What will do this code
Rasbabieh
which header file can I use in linux to work as conio.h?
Anonymous
Error in do
You can't write do while loops in global or namespace scope. They must be used within a function or a method.
Anonymous
Yes it is a good book. Use the latest edition
Madhukar
Hi
Anonymous
I thought that the 6th edition was already released but apparently not. You will have to use the 5th edition and then upgrade yourself for changes introduced in C++14, 17 and 20. I recommend isocpp.org to find the new changes and learn about them from other books or online blogs (there are tonnes of them)
der ðiβüśüɾę
Guys, maybe can you know about compile c++ to exe on linux?
Crow
I can't find "while()"
Crow
maybe do{ }while();
Suka
Guys, maybe can you know about compile c++ to exe on linux?
its called cross compile you need compiler that support produce win exe like mingw package try searches your repo many big distro already have it.
klimi
Saleh
Guys, maybe can you know about compile c++ to exe on linux?
https://stackoverflow.com/questions/38786014/how-to-compile-executable-for-windows-with-gcc-with-linux-subsystem Check this, maybe this will be useful (answer there is similar to what you want). Newer tried to do this on Linux for Windows.
der ðiβüśüɾę
Fine, thanks
der ðiβüśüɾę
But wine says 010c:err:module:import_dll Library libgcc_s_seh-1.dll (which is needed by L"Z:\\home\\dibusure\\projects\\passGen\\main64.exe") not found 010c:err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\dibusure\\projects\\passGen\\main64.exe") not found 010c:err:module:LdrInitializeThunk Importing dlls for L"Z:\\home\\dibusure\\projects\\passGen\\main64.exe" failed, status c0000135
der ðiβüśüɾę
That's not fine...
Crow
lol,not fine
der ðiβüśüɾę
I writed x86_64-w64-mingw32-g++ -o main64.exe gen.cpp for compile
der ðiβüśüɾę
and wine cmd for cmd console, and execute main64.exe
Suka
and wine cmd for cmd console, and execute main64.exe
sorry iam using artix. try list file from your mingw packages iam sure you can find requested dll n copy it to your project folder
Suka
or you can search google for that dll