Hisam
i tried to change 'i' to 'inch' but vscode showing this warning "result of comparison of constant 1768842088 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare]"
Anonymous
Anyone tell me how to clone a any web script plzz .!
Anonymous
🥺🙄
Talula
test.cpp:13:17: warning: multi-character character constant [-Wmultichar] 13 | if (unit == 'inch') | ^~~~~~
You put char in ' (single quote) and " for a string... (Double quote).
Kartik
Is "constexpr" good to use here, why not just const?
Anonymous
/rules
Kartik
u try to change in line 13?
I changed constexpr to const and it worked
Hisam
You put char in ' (single quote) and " for a string... (Double quote).
and now got this test.cpp: In function ‘int main()’: test.cpp:13:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | if (unit == "inch")
Kartik
Constexpr is available in C++11 onwards
Hisam
I changed constexpr to const and it worked
const or constexpr also work but it possible to change 'i' to 'inch'?
Hisam
i try to change 'i' to 'a' also work maybe only single character?
Hisam
sorry for my english😅
Talula
char
char is a single byte you can't compare it with string...
Talula
declare it as string.
Kartik
declare it as string.
Along with that, I think there is a function that does this job...I don't remember exactly. Am I right?
Talula
how about array?
You can use array of char and use strcmp to compare the string.
Anonymous
Bhai course dedo
Luis
## Rules #pinned * You are not entitled to an answer, getting angry about not answered questions will get you warned. * Not checking your problem in google (or any other search engine) first will get you a warn. * Asking to solve an assignment/test/whatever without trying it first yourself will get you a warn or will get you BANNED. We won’t write a code for you, but we can push you forward and suggest something. * Before posting a long code snippet think twice and read the Resources section below. * No “best book” or “best youtube channel” requests, use /get cbook and /get cppbookguide chat commands. * No “best ide” requests, use /get ide chat command to see the suggestions. * Asking for something that is in the pinned message right after joining WILL GET YOU BANNED. * C/C++ discussion preffered (assembly also allowed), asking about other languages (or groups for other languages) right after joining will get you BANNED. * Reverse enginnering, hacking and related topics are allowed, but asking to hack facebook, instagram, etc. is NOT allowed. Also if you ask "how to become a hacker" and obviously have zero knowledge on anything related to that you may get warned or banned. * Legitimate requests for help on code and programming questions are welcome. A request is considered legitimate if it describes your problem, what you've done so far and what went wrong. Requests such as "write my program" or "do my homework" are never considered legitimate. Asking not legitimate questions will result in a warn or ban. See https://stackoverflow.com/help/mcve on how to write good questions. * Asking for book recommendations is ok, but "pls give pdf book" is not allowed, find books by yourself. Posting illegally copied books (or links to those books) is also not allowed and will get you BANNED. * Only English language is allowed, if you speak shitty English or don't understand anything in English YOU WILL BE BANNED. * A little bit of programming related memes, jokes, shitposting are allowed. * NSFW content (porn, nudity, etc.) is not allowed. * Spamming/advertising (job posts are also ads, so ask an admin before posting) will grant you a warning or an immediate ban if you do it right after joining. * Religion, politics and ideological topics are forbidden. * Long code snippets must be posted via a snippet website(links below), posting pictures of code and posting long snippets in the group is not allowed. * If you encounter a problem, while using dev C++ or turbo C/C++, you will not be helped, use another more modern IDE. * Don't post compiled executables, that is obviously a security risk. * Personal messages without asking beforehand are not allowed. * If you want to post a link or some article in this chat you will need an admin approval first ## Resources C/C++ group India: http://t.me/c_cpp_india About asking good questions: * [English](http://www.catb.org/esr/faqs/smart-questions.html) * [Translations](http://www.catb.org/esr/faqs/smart-questions.html#translations) For posting long code snippets: * [GitHub Gist](https://gist.github.com) * [Ubuntu Paste](https://paste.ubuntu.com/) * [Pastebin](https://pastebin.com) ## Reports If you notice any forbidden content, please use the /report command while responding to the offending post to report it to the admins.
👍👍👍 it's understood
Safwan
Anyone to guide me!
Pavel
Anyone to guide me!
Hi, you can ask specific questions so people can give answers.
Mickey🕷
Can't you try it out on your compiler? You must read about operator precedence and associativity to understand how these expressions are evaluated.
This was from a theory paper that you write without the computer. The compiler gave me the answers but I didn't know how you get to them. Now I understand though.
Pavel
Is there a standard way of combining multiple hashes (not necessarily STL standard, but rather industry standard)? For example for hashing a struct or array. I see in the answers on the internet people suggest different custom functions without providing any background why exactly these ways with these magical constants. Also most of them based on bitshifts, but we have std::rotl and std::rotr now that feel as a better way to rotate bits without loosing data.
Ludovic 'Archivist'
Yes, and you can optimize that by using a hash function that takes a stream of integers that are also potentially valid hashes
Ludovic 'Archivist'
for example, murmur gives you hashes the same size as its input iirc
Pavel
Interesting, thanks @QNeko This sounds really reasonable
Ludovic 'Archivist'
👍
جند
Guys
جند
Im just a begginer and i need someone to help me
Lucas Guedes
Hello everyone. Anyone knows if is there a way to create a scrollview with OpenGL and C++?
Lucas Guedes
I've searched on internet but unfortunately don't found anything
Anonymous
?
suleiman
Hi
suleiman
Good morng everyone
suleiman
What is recursition
suleiman
Pointer and reference in c++?
suleiman
And different between identatiin and recursion
Dr
What is recursition
Calling same function within function
Anonymous
* * **** Can I get help to write this program
Pavel
Im just a begginer and i need someone to help me
Hi, it will be very difficult to answer your question if you never ask it. Can you provide more info about your problem?
Pavel
Hello everyone. Anyone knows if is there a way to create a scrollview with OpenGL and C++?
For scroll view you need to implement two things: - positioning of elements - clipping Positioning is easy, you need to calculate the total height of the content inside the scroll. You have position and the size of the scrollbar, and you have the scroll offset (which is some value from zero to content height minus scrollbar height). You can calculate position of each element from that data knowing it position in the content: scrollbar position + offset + position of the element. E.g. you have content with 1500px size, you have a button that is in coordinates 10px, 1300px in this content, you have the scrollbar position as 20px 30px in the window and with height of 300px. And it's scrolled down (offset) by 40 px. So your button will be in coordinates 20+10=30 by x and 30+40+1300=1370 by y in window coordinates. I used pixel coordinates for simplicity, you probably will have floating point coordinates of your choice, it should work for any. The clipping part is more complex, idea of clipping is to hide parts of the content that should not be visible. You can use masks or render to texture for that. You can Google more info about both.
Pavel
What is recursition
Hi, this is a big topic and it explained on the internet very well, you can have more luck just googling it rather that waiting for someone to repeat that information from the internet to you. Same goes for pointers, references and indentation. If you tried to read that and don't understand you can quote/link the part of the explanation that is unclear and describe what is unclear in that part, then it will be much easier to help you.
NagaRaju
I'm stuck here!! I found this question on hackerrank. I'm trying to solve since two days but every time I try its not working . Q : Parallel processing A computer has certain number of cores and list of files need to be executed. If a file is executed by a single core, the execution time equals to the number of lines of code in the file. If the lines of code can be divided by the number of cores, another option is to execute the file in parallel using all the cores, in which case execution time is divided by the number of cores. However, there is a limit has to how many files can be executed in parallel. Given the lengths of code files, the number of cores, and the limit, what is the minimum amout of time needed to execute all the files ? For example let's say there are n = 5 files, where files = [4, 1, 3, 2, 8](indicating number of lines of code in each file) , numOfCores = 4, limit = 1. Even though both the first and fifth file can be executed parallel, you must choose only of them because the limit is 1. The optimal way is to parallelize the last file, so the minimum execution time required is 4 + 1 + 3 + 2 + (8/4) = 12. Therefore, the answer is 12. ======================== Function parameters : long minTime (int files_count, int* files, int numCores, int limit); int main() { // call minTime(); } languages : C / C++ / java ================ My code: long minTime(int files_count, int* files, int limit) { long min_time; for (int i = 0; i < fikes_count; i++) { if (files[i] % numCores == 0) { files[i] 6 files[i] / numCores; } min_time += files[i]; return min_time; } } Please slove this and explain for me . Thanks
olli
I'm stuck here!! I found this question on hackerrank. I'm trying to solve since two days but every time I try its not working . Q : Parallel processing A computer has certain number of cores and list of files need to be executed. If a file is executed by a single core, the execution time equals to the number of lines of code in the file. If the lines of code can be divided by the number of cores, another option is to execute the file in parallel using all the cores, in which case execution time is divided by the number of cores. However, there is a limit has to how many files can be executed in parallel. Given the lengths of code files, the number of cores, and the limit, what is the minimum amout of time needed to execute all the files ? For example let's say there are n = 5 files, where files = [4, 1, 3, 2, 8](indicating number of lines of code in each file) , numOfCores = 4, limit = 1. Even though both the first and fifth file can be executed parallel, you must choose only of them because the limit is 1. The optimal way is to parallelize the last file, so the minimum execution time required is 4 + 1 + 3 + 2 + (8/4) = 12. Therefore, the answer is 12. ======================== Function parameters : long minTime (int files_count, int* files, int numCores, int limit); int main() { // call minTime(); } languages : C / C++ / java ================ My code: long minTime(int files_count, int* files, int limit) { long min_time; for (int i = 0; i < fikes_count; i++) { if (files[i] % numCores == 0) { files[i] 6 files[i] / numCores; } min_time += files[i]; return min_time; } } Please slove this and explain for me . Thanks
What have you done so far? Where is your code? If you're stuck since two days, what were your attempts?
NagaRaju
What have you done so far? Where is your code? If you're stuck since two days, what were your attempts?
My code: long minTime(int files_count, int* files, int limit) { long min_time; for (int i = 0; i < fikes_count; i++) { if (files[i] % numCores == 0) { files[i] 6 files[i] / numCores; } min_time += files[i]; return min_time; } }
Pavel
hooray censorship in the chat
klimi
hooray censorship in the chat
Yes, now please stop
Peace
which execution will be fast for array printing ?? https://pastebin.com/TR1XcYPz array<double,4>
Mateus
Hello guys, how to fix this problem: aes.h [Error] openssl/opensslconf.h: No such file or directory
Anonymous
My code: long minTime(int files_count, int* files, int limit) { long min_time; for (int i = 0; i < fikes_count; i++) { if (files[i] % numCores == 0) { files[i] 6 files[i] / numCores; } min_time += files[i]; return min_time; } }
Where have you used the fact that only 'limit' files can be processed in parallel and more importantly where have you taken into consideration the parallel processing time?
Anonymous
Hello guys, how to fix this problem: aes.h [Error] openssl/opensslconf.h: No such file or directory
Probably need to add the include directory of openssl header files to the include directory path of your project. Just search google for how you can do this for the specific IDE or compiler you are using
Anonymous
which execution will be fast for array printing ?? https://pastebin.com/TR1XcYPz array<double,4>
Why do you expect one to be faster than the other? They should provide the same performance on any decent compiler.
Anonymous
which execution will be fast for array printing ?? https://pastebin.com/TR1XcYPz array<double,4>
if you want to have fun iterating an array you can try this method haha, but in terms of safety use standard ways or range based for loop int main() { int const size = 5; std::array<int, size> v = { 1, 2, 3, 4, 5 }; int* begin = &v[0]; int* end = &v[size - 1]; do { std::cout << *begin << ' '; ++begin; } while ( begin <= end ); }
Anonymous
is it always better to use pointers ?
no, the efficiency of the code is also given by its security, just use what the c++ API offers, every compiler can perfectly optimize such simple codes
Mateus
Hello guys, how to fix this problem: aes.h [Error] openssl/opensslconf.h: No such file or director
Mateus
Windows
Mateus
I need run aes for encrypt password.
olli
My code: long minTime(int files_count, int* files, int limit) { long min_time; for (int i = 0; i < fikes_count; i++) { if (files[i] % numCores == 0) { files[i] 6 files[i] / numCores; } min_time += files[i]; return min_time; } }
It seems like you're not using the limit at all? You probably only want to divide the biggest files, as processing these in parallel yield the highest time savings. E.g. Files : [16, 24, 32, 8, 4], limit: 2, numCores: 4 In this case you could choose any two files to process in parallel but choosing the biggest two (32, 24) gives the best result Also your return statement should be outside the for loop
olli
Can you suggest code implimentation for me?
Depending on the constraints, try to sort the files first. Afterwards starting with the biggest, if you can divide it and you have not used parallelization limit-times, divide it by the number of cores.
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
#include <iostream> using namespace std; string CustomerDetails(string name){ cout<<"\n***** Welcome "<<name<<" *****"<<endl; cout<<"\n"; return name; } int unitConsumed(double previous,double current){ double unit; unit = current - previous; return unit; } string customerType(){ string domestic = "Domestic", industrial = "Industrial", commercial = "Commercial"; double p,c; if (unitConsumed(p,c) < 100){ return domestic; } else if (unitConsumed(p,c) > 100 && unitConsumed(p,c) <= 200){ return industrial; } else if (unitConsumed(p,c) > 200) return commercial; } } int main() { string name; cout <<"Please Enter Your Name: "; getline(cin,name); // CustomerDetails(name); double currentMeter, PreviousMeter; cout <<"\n\nEnter Previous Meter Reading (kwh): "; cin>>PreviousMeter; cout<<"\nEnter Current Meter (kwh): "; cin>>currentMeter; unitConsumed(PreviousMeter, currentMeter); cout<<"\n"; cout<<unitConsumed(PreviousMeter, currentMeter); cout<<"\n"; cout <<customerType(); return 0; }