Anshul
then I dont understand why not use std::count
I thought that person wanted to make a number of queries
Anshul
then I dont understand why not use std::count
If just one query is to be made then this is better
Anonymous
Hey, guys a quick question: auto map = std::unordered_map<std::string, int>("string", 5); why I can't construct a temporary unordered_map with a key of std::string type
These are the constructors available for an unordered_map. https://en.cppreference.com/w/cpp/container/unordered_map/unordered_map Which of these constructors does your call match?
Ángel
Compile with -fsanitize=address and link with -lasan.
I get an error. Library not found for -lasan. I don't find it to download and put it in my project.
Ángel
Instead of -lasan try -static-libasan
No working! Unknown argument. I am using gcc in Mac. Am I missing any library? Thanks so much help!
Anonymous
No working! Unknown argument. I am using gcc in Mac. Am I missing any library? Thanks so much help!
On MAC as far as I know, gcc is usually an alias for Clang. On older versions of the compiler you had to link to the .so or .a versions of the address sanitizer library. Now, just the option -fsanitize=address or -fsanitize=leak should be good enough. Try that.
Dr
No working. No idea what is missing
Did you install gcc directly?
Dr
You’ll have to install Something called Xcode i guess! I remember my friend telling me ! I’m not sure but let me ask him and get back to you
Pavel
xCode can be installed from appsrore on mac. It actually has some good sanitizers
Ángel
Did you install gcc directly?
It was installed already! Thanks everyone for the help!!!
Anonymous
Working! 🥳 I put the flag in compilation and linking! -g -fsanitize=address It shouldn't be like that, but maybe I have something wrong in my makefile
That is what I told you. You can add them to CPPFlags in Makefile as well if your build is a debug build. Make sure you don't have those flags on a release build
Nils
Like const char *strings[]
Leel
Kindly help me complete my assignment.
Anshul
Kindly help me complete my assignment.
Kindly go through Pinned rules
Ángel
For me is easier to see: (but same) int I, j; char strings[ ] [ ]; strings[i ] [ j] = 'a';
Andrii
Hello. In CLion debugger I have char with value -47 '\321'. What does '\321' mean? Don't know how to google it.
Oky--
Direct massage
nino
Hi guys, can someone help me With the code I need to create for the university?
Anonymous
Hi guys, can someone help me With the code I need to create for the university?
This is a C/++ group. You are meant to ask questions here
Andrii
nino
This is a C/++ group. You are meant to ask questions here
The track of the exercise is in pdf and I cannot send it to the group, can I write to you in private?
Krishnaa
#include<iostream> using namespace std; void Merge(int a[], int l,int mid,int r){ int i, j, n1=mid+1-l, n2=r-mid, n3=n1+n2; int x[n1], y[n2], res[n3]; for(i=0; i<n1;i++){ x[i]=a[l+i]; } for(j=0; j<n2; j++){ y[j]= a[mid+1+j]; } i=0; j=0; int k=l; while(i<n1 && j<n2){ if(x[i]<=y[j]){ a[k]= x[i]; i++; } else{ a[k] = y[j]; j++; } k++; } while (i < n1) { a[k] = x[i]; i++; k++; } while (j < n2) { a[k] = y[j]; j++; k++; } } void MergeSort(int a[], int l, int r){ while(l<r){ int mid = (l+r)/2; MergeSort(a, l, mid); MergeSort(a, mid+1, r); Merge(a, l, mid, r); } } int main(){ int arr[]={9,7,8,4,2,1}, n=6; MergeSort(arr, 0, n-1); for(int i=0; i<n; i++){ printf("%d ",arr[i]); } return 0; }
The
No I don't do your exercise But if you have question , you can ask it here
Leel
Here image sharing is not allowed, Can I send you in private?
Leel
Please help me with my question
Krishnaa
Are u want to sorting ur array
Yes. Did u find out what's wrong with that code?
Anonymous
Yes. Did u find out what's wrong with that code?
Didnt I already tell you what the problem is? Try working on the case I gave you and you will see why the function MergeSort and hence your program will go Into an infinite loop.
Anonymous
Yes. Did u find out what's wrong with that code?
And in future learn to use a debugger.
Krishnaa
And in future learn to use a debugger.
I never tried it till now. Coz I don't know how it works.
Anonymous
I never tried it till now. Coz I don't know how it works.
If you want to be a programmer then you must.
Krishnaa
If you want to be a programmer then you must.
Yeah atleast I'll starting using it from now on.
Anonymous
Yeah atleast I'll starting using it from now on.
So did you understand what is wrong with your code?
Anonymous
Why my messages deleted
Ludovic 'Archivist'
please use pastebin or a similar tool to post long stretches of code
Anonymous
@area_av If you want to post code, use pastebin
Anonymous
How
Anonymous
How
pastebin.com
Anonymous
Yeah atleast I'll starting using it from now on.
I think u must do it with bubble sort algorithm
Anonymous
I think u must do it with bubble sort algorithm
He is not asking for help with sorting. He is asking for help wrt his specific code which is mergesort which is much faster than bubble sorting. It would be even faster if he had used in place merging.
Krishnaa
So did you understand what is wrong with your code?
Bro, I can't understand what's happening with this debugging
Krishnaa
.
Using merge sort!
Krishnaa
Says, Starting program: /home/a.out and expects me to type in something. What do I need to type there?
Anonymous
Bro, I can't understand what's happening with this debugging
If suppose say l is 0 and r is 1 then your while loop condition l < r will never be false.
Anonymous
Says, Starting program: /home/a.out and expects me to type in something. What do I need to type there?
You will have to first compile your code with -g flag. You will have to learn gdb commands. You have set breakpoints. You can set a breakpoint at any line of your code. You can then step through your code, check your variables and stuff as the program is executing
Krishnaa
If suppose say l is 0 and r is 1 then your while loop condition l < r will never be false.
Yeah got it. But where do I need to place 'mid' to break that while
Krishnaa
Bro bro
Krishnaa
I got it
Krishnaa
It's not at all about while
Anonymous
Yeah got it. But where do I need to place 'mid' to break that while
If r -l is <= 1, then there is nothing to do. Only if r-l is > 1, you will have some work to do.
Krishnaa
?
After u told me that, I realised and replaced while with if
Krishnaa
It worked perfect.
Anonymous
After u told me that, I realised and replaced while with if
Which is what I said in my first reply. Recursion is equivalent to a loop itself. I was just trying to make you see what the problem is.
Ludovic 'Archivist'
https://archivist.nekoit.xyz/concurrency-with-nothing/
Pavel
Please help me with my question
Why do you need an image for that? If you want to share code you can use pastebin
Knights
I’m trying to access a file called RainOrShine in my code but it always fails to open I’ve included the fstream header file already Here’s the code ifstream weatherfile; weatherfile.open(“RainOrShine”); If (weatherfile.fail()) count<<“file was not opened successfully”<<endl; Else count<<“file successfully opened”<<endl; PS: RainOrShine is in a folder called Chapter 07 which is also in a c++ folder on the desktop It always fails to open Please help me fix this
Ch
Hello
Anonymous
#include "stdio.h" #include <stdio.h> Whats diffrence?
yoo
Hi
yoo
I am totaly new to c++, I have never learnd any programming language it's my first language to learn how to learn it free?
Pavel
I’m trying to access a file called RainOrShine in my code but it always fails to open I’ve included the fstream header file already Here’s the code ifstream weatherfile; weatherfile.open(“RainOrShine”); If (weatherfile.fail()) count<<“file was not opened successfully”<<endl; Else count<<“file successfully opened”<<endl; PS: RainOrShine is in a folder called Chapter 07 which is also in a c++ folder on the desktop It always fails to open Please help me fix this
Either one, or another, or both: 1. Try to put your file in the same folder where your working directory is, without subfolders. You can find your working directory in your IDE settings, if you don't use IDE, then it's the folder where you run your .exe The command that you're calling need the path to the file, if you just specify the filename it assumes that the file is accessible directly from the working directory, it won't search all your hard drives for this file. You can also try creating a file using std::ofstream and then searching where that file was created, to determine the working directory. 2. Check that your file doesn't have any extensions, e.g. .txt (if you can open the file with Notepad by doubleclicking, then it is likely .txt). If the file has an extension, you should specify it in the command, e.g. "RainOrShine.txt". You can enable showing extensions on windows to make it less confusing https://vtcri.kayako.com/article/296-view-file-extensions-windows-10
yoo
YouTube...
Which channel
Talula
Which channel
There is something called "Search" on the top, which you could use to Search for "Beginners Programming C++" and you'll get the results.