Anonymous
Sounds perfect
Nurlan
Vim
Лол
Abishek khanna
How to download C / C++ for Windows
Anonymous
hello every one
Anonymous
What do you think about joining an international programming group?
Pavel
I mean something like this int n = 10; int m = 20; char arr[m*n]; // getting element [5][10] char elem = arr[10*n+5]; Also there is support for multidimensional arrays in the language, but you probably already googled it https://beginnersbook.com/2014/01/2d-arrays-in-c-example/
Aakarsh
https://pastebin.ubuntu.com/p/WmcyP4mkRB/ I'm not able to make threads read and write a file. Could you check where I'm doing things wrong?
Aakarsh
So you suggest that I should keep a global variable that would act as flag which would keep track of when the data is written right? And about the while loop, what else could be the substitute for this
Aakarsh
Ok I will read about it
Aakarsh
Gotcha! Will work on this
Vlad
Isn't conditional var some sort of busy loop with a small sleep after the check?
Alex
Isn't conditional var some sort of busy loop with a small sleep after the check?
no. kernel announces when conditional is true. your programs sleeps all time
Vlad
no. kernel announces when conditional is true. your programs sleeps all time
But it doesn't mean that it doesn't do it under the hood. Your user code execution is blocked I agree.
Alex
but conditional variable consumes more time for switching than "busy loop"(active polling)
Vlad
no cpu utilization, check it in process manager
It just goes into the sleep state. Which offloads cpu.
Alex
It just goes into the sleep state. Which offloads cpu.
but there is no loop with sleep. it uses event from linux kernel(if you have linux) which wakes up your process if condition occurs
Vlad
but there is no loop with sleep. it uses event from linux kernel(if you have linux) which wakes up your process if condition occurs
I tend not to think that it's just magic in the kernel. It's probably the same deal with loop inside.
Vlad
https://github.com/torvalds/linux/blob/master/kernel/futex.c It has loops strangely enough and many retries and waits. I see your point that is more efficient than just a busy loop. But you can't get around loops for event handling.
Anonymous
https://youtu.be/QsZOUqgsvwM
Anonymous
how do i make getdelim() reentrant/thread safe? how to deal with user passing the same FILE * to two instances of the function? https://github.com/chandradeepdey/C_inputlib/blob/master/src/inputlib.c
Anonymous
all i see on googling thread safety is don't use global (external?) variables. but what if the function needs them to work ;-;
Vlad
However it doesn't mean that there's no main game loop or smth.
Anonymous
i was about to say "but the getline() manpage says it is MT-safe", then i read what MT-safe means for glibc for the first time. "Being MT-Safe does not imply a function is atomic"
Anonymous
i assumed MT-safe meant it was atomic, calling on two threads simultaneously would get two different lines instead of one character from the string on this thread and one character on that thread.
Anonymous
so i wanted my function to be atomic too
Anonymous
What do you think about joining an international programming group?
Anonymous
👌😁
Anonymous
You are already in one
yes but all programming language
Harsh
yes but all programming language
It's good till you're learning something
din va lu
Hyy
din va lu
Anyone please help me....
din va lu
I want to read two string using getline function in a loop.
din va lu
After that I want to do some functions with each string
din va lu
How it will code in c++
din va lu
Anyone plzz......Help me.....
Kenny
Hey, are you reading from a file no?
Harsh
How it will code in c++
You already stated the solution 😃
Harsh
loop(2) read str1, str2 some_func(str1) some_func(str2) But why you need loop🤔
Harsh
Please state the exact problem
din va lu
Please state the exact problem
I want to read n number of string and to print each string having the even indexed character first and odd indexed after space.each string will be want to be in new line
din va lu
Input: Hello Hai Output: Hlo el Hi a
din va lu
Help me
din va lu
So, what have do done so far?
I don't know how to code that
din va lu
Can any one tell that
Aakarsh
wouldn't it be for c++?
din va lu
Ismael
Thanks 😊
Anonymous
oh
Harsh
void oddEvenIndices(char str[]) { for(int i = 0; i < strlen(str); i++) if(i % 2 == 0) cout << str[i]; cout << endl; for(int i = 0; i < strlen(str); i++) if(i % 2 != 0) cout << str[i]; }
Harsh
Might get compiler warnings
Anonymous
So ohky guys...where should I start if is for my first...Wich app to download for C++
Vlad
/get ide
Anonymous
OS?
Meaning?
Vlad
Meaning?
What operating system do you use
Anonymous
U mean laptop or mobile phone?
Vlad
U mean laptop or mobile phone?
I mean what's your laptop/pc OS.
Dima
bruhhh
Dima
learn a bit of basics first before c++