Anonymous
how do i get this to be able to do LOGGER_OSTREAM() << 5 << std::endl; like i can for Stream() << 5 << std::endl; https://wandbox.org/permlink/gBxFeBtK1rDO6uPu
hamza
guys you can use these to mention that it's a block of code
hamza
something here
hamza
( use ` three times for each in the beginning and the end of your block of coe
hamza
C #include<iostream> using namespace std; int main() { int i,N; //entering number of integers that arr will contain cin>>N; int arr[N]={}; for(i=0;i<N;i++) {cin>>arr[i]; //inputting arr elements } //for printing elements in reverse order for(i=(N-1);i>=0;i--) {cout<<arr[i]<<" "; } return 0; }
Peace
when we run this program, given input gets overwrite on the previous given input in console. how to can we get input in new lines without overwriting the previous one ? // Program to make a tollBooth class const char ESC=27; const double toll= 0.5; class tollBooth{ unsigned int total_cars; double money; public: tollBooth():total_cars(0),money(0){} void pay_cars(){ total_cars++; money+=toll; } void non_pay_cars(){ total_cars++; } void display(){ cout<<"Number of paying cars: "<<total_cars<<endl <<"Number of amount collected: "<<money<<" cents"<<endl; } }; int main(){ tollBooth booth1; char ch; cout<<"\nPress 0 for paying car\nPress 1 for non paying cars\nPress ESC to exit program"<<endl; do{ ch = getche(); if(ch=='0'){ booth1.pay_cars(); } if(ch=='1'){ booth1.non_pay_cars(); } }while(ch!=ESC); booth1.display(); return 0; }
Anonymous
Hello everyone
hamza
Variable length array is on ISO C but not in C++, it's GNU Extension
I just gave the example how to use these ('`') to make it codish
klimi
Hello everyone
nohello.com
MAMAK
someone can help me please
MAMAK
Develop a program that finds how many 0s at the end of the number that will be multiplied by N numbers. Note: There is no restriction for N pieces or their small size.
MAMAK
It is difficult to understand your question as you have framed it. Perhaps an example might help.
For example i want give 3 different number : 5,10,100 you must make 5*10*100 and program must tell me in that number have 3 Zero(0) at Last Just on the end not in first (i m talking about 0 for example 4000300 have Just 2 zero 5000 have 3 Zero
Anonymous
For example i want give 3 different number : 5,10,100 you must make 5*10*100 and program must tell me in that number have 3 Zero(0) at Last Just on the end not in first (i m talking about 0 for example 4000300 have Just 2 zero 5000 have 3 Zero
For each number in the product, find out how many times it is divisible by 2 and divisible by 5. Add the powers of 2 separately and the powers of 5 separately. The minimum of these 2 values will be the number of zeros at the end of your product. For ex 24*125*750 24 can be divided by 2 - 3 times and 5 - 0 times. 125 can be divided by 2 - 0 times and 5 - 3 times. 750 = 125*2*3 can be divided by 2 - 1 time and 5 - 3 times. Therefore total 2s is 4 and total 5s is 6. The number of trailing zeros will be the minimum of the two i.e. 4.
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
cout << "Please Enter Your First Name: "; cin >> fname; char *firstname = new char[fname.length()]; for (size_t i = 0; i < fname.length();i++ ){ firstname[i] = fname[i]; }
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Anyone has an idea what I’m doing wrong?
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Cout << firstname;
Anonymous
Cout << firstname;
That is the problem. The dynamic array pointed to by firstname is not null terminated. So your program will exhibit Undefined Behavior as it will try to print till it encounters a null character. You have to reserve space for the null character and add it at the end of firstname
Anonymous
How do i do that? char *firstname = new char[fname.length()+ 1]?
Yes. And set the last entry in the array to '\0' or simply to 0
Mikhail
Hello everyone, i was writing a console application on windows: i was writing and reading data from .txt files in cyrrilic symbols. Everything was OK but since i switched to mac there are many problems in encoding for cyrillic symbols in txt files on mac. Can someone help me with this problem?
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Yes. And set the last entry in the array to '\0' or simply to 0
Bro how do i set the last character to ‘\0’🥲
Mikhail
Clion dropping me this: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) because i am trying to read Ablo 22 2000 –Я–Ь from file (i suppose to say). There must me cyrillic symbols instead of ''–Я–Ь'', what is the fastest way to solve this problem?
Anonymous
Bro how do i set the last character to ‘\0’🥲
firstname[fname.size()]='\0';
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Maksim
/get cppbookguide
Mikhail
What is the encoding used for the text file? It could be that Mac doesn't support that encoding
The problem is that I need to read/write Cyrillic symbols. In Clion I use UTF-8, in text editor - Windows Cyrillic
Golden Age Of
The problem is that I need to read/write Cyrillic symbols. In Clion I use UTF-8, in text editor - Windows Cyrillic
So, here are a few ways: set your's console coding to chcp1251, set your cpp file encoding to chcp1251, or same simultaneously In more situations that should work
Mikhail
I've solved the problem: the problem is that mac cant read cyrrilic symbols in .txt files which was created on Windows. I've delete and created this files on mac and the problem has been solved
arfa
anyone know about shape and color game in c?
\Device\NUL
anyone know about shape and color game in c?
must be conio or ncurses thing (?)
Golden Age Of
no meta questions for first, for second its C/C++ group
Apk
You can easily search them online for most problems.
𝙰𝚖𝚖𝚊𝚛
Hello everyone, I would like to ask if I could put int and char in the same array, or something like that.
Shaniya 🕊
Any another material which help me in interview ( internship )
Shaniya 🕊
Means
\Device\NUL
Hello everyone, I would like to ask if I could put int and char in the same array, or something like that.
actually, char is short short int ASCII char is represented in integer value.
Lore
Hi, could you tell me why y never takes 0 as a value in this program? https://pastebin.com/aMRfq76Q
Manish
Hi, could you tell me why y never takes 0 as a value in this program? https://pastebin.com/aMRfq76Q
Seems, y=0, for x=1, -2. But loop never touches values of x where is 0.
Anonymous
Hi, could you tell me why y never takes 0 as a value in this program? https://pastebin.com/aMRfq76Q
That is because of floating point inaccuracies. A value such as 0.1 is not exactly represented as 0.1. They are approximations. So you shouldn't assume that reducing 10 by 0.1 consecutively would reach 1 or -2. It will be a value close to those values but not equal.
Abdulaziz
how could i go about solving?
Round every value every time
Anonymous
how could i go about solving?
You have to use epsilon approximations. Search for it on Google. You might get an answer such 6.9e-19 which in all likelihood is a 0. So you assume it is 0 and move on. Ifyou need exact accuracy, you have to use libraries that support decimal numbers instead
Anonymous
Hello I wrote a function for replacing in string but it not work correctly After replacing that destroy array For example if src = "0123456789" And text = "AAA" Start_point = 3 End_point = 7 Src will be = "012AAA" Why this happen? void replace(char src[], char text[] , int start_point , int end_point){ int i,j=0; for(i=start_point;i<end_point+1;i++){ *(src+i) = text[j]; j++; } }
Joe
Thanks
Suka
actually, char is short short int ASCII char is represented in integer value.
yups but in modern cpp char is used to hold 1 character and it can be ascii or unicode(utf8, utf16, or 32) cmiiw
Junaid
Can some one recommend me Some DSA projects for my smster
Ludovic 'Archivist'
Ludovic 'Archivist'
People tend to not expect the same stuff from an undergrad and a last year of doctorate
Ludovic 'Archivist'
yups but in modern cpp char is used to hold 1 character and it can be ascii or unicode(utf8, utf16, or 32) cmiiw
It is kinda complicated. The standard says that any utf code point below 128 is validly represented in strings and string literals, but that the rest is implementation defined
Ludovic 'Archivist'
But it probably works
Ludovic 'Archivist'
yups but in modern cpp char is used to hold 1 character and it can be ascii or unicode(utf8, utf16, or 32) cmiiw
Just... Don't sneeze too close from nvcc or you may paint your monitor with shoe polish
Morsal
Hi all. If (a ="120" , b= "100" )are objects of class [STRING] and [ STRING c = a + b ] . How to make [operator +] that make c = 220 ?
Felix
i don't think you can do that except you're using int/float variable
S__R
https://pastebin.com/JsFU1YjF Morsal u can use this logic try to do it
Anonymous
The instructions on that GitHub page clearly state what you need to do to build the library. So why can't you follow those instructions and build it yourself?
Anonymous
I tried, but since I'm not familiar with ninja, appveyor & cmaker I failed.
You don't have to be familiar with them. They have given the instructions to follow. JFYI, CMake is a build manager and generates the build file. In the case of this specific library that you are using, it uses the Ninja generator to generate a ninja build file. Ninja is just a build tool and it uses the .ninja buildfile generated by CMake to build your source code. CMake can be used to generate any build file. It can be used to generate a Visual Studio .sln file as well. In this case, they generate .ninja files. Hopefully that makes it clear. Appveyor is a Continuous Integration tool. I am not sure why that is relevant here. As long as you have CMake, build-ninja and the other dependencies (they have mentioned how to install them as well) installed, I don't see what can be so troubling that you need others to help you with it.
Nils
Their API gets hate just because it's Microsoft lol But it's very good Well, maybe not 'very good', but it's good
Actually... What's absolutely terrible is how there are like 10 variations of each function of which the half are deprecated or something
Nils
And how badly stuff (for instance winhttp) is documented, it took me like a half day to do a webhook request to Discord in it lol
Nils
It took me about 5-10 minutes to do the same in curl