Pavel
I still can't find why am I getting a seg fault. I have tried to debug it. Can anyone help
It's likely that your array was in static memory and you accessed some memory that your app is not allowed to access. But that doesn't matter, because it's UB. We don't need to investigate results of UB
Yasas
Do I need visual studio for c++?
Takshveer
Appka mobile number chia mako
Pavel
Do I need visual studio for c++?
Not necessarily, you can use other IDEs
Talula
Do I need visual studio for c++?
You don’t need it but you could use it.
Yasas
I have Clion but I need more
Talula
What are the other ides?
There aren’t IDEs you could use Dev-Ops which is an IDE but other are editors…
Yasas
Is there offline installers for visual studio 2019?
Anshul
Int a[10]={0};
Anshul
Will this initialise all elements of array 0
Anonymous
Will this initialise all elements of array 0
Yes. But couldn't you just have tested this on your computer instead of asking the question here?
Anshul
And if the array was bool array instead of int? Still can I initialise it with 0 ?
Yasas
Use CodeBlocks
It's for people who don't have productivity
'''''''
It's for people who don't have productivity
use notepad as the editor and run your program through command prompt
Anonymous
Is there offline installers for visual studio 2019?
the installer can download stuff separately from installation. you can copy the downloaded files for offline installations. but Visual Studio changes very often with updates in the gigabytes range, so it probably isn't worth it unless you are installing to a thousand pcs at once.
@𝑺𝒐𝒃𝒌𝒂
It's for people who don't have productivity
Really? I'm curious. I want to know why?
Whistleblower
Can anyone tell me the applications where we can use the shared memory IPC mechanisms?
Anonymous
Can anyone tell me the applications where we can use the shared memory IPC mechanisms?
In the "map reduce" algorithm, the different reductions need to be able to store data at a common location. This is not exactly what you asked for (because map reduce is ideally done on distributed system rather than on a single system) but the idea is that wherever you need work to be distributed among different workers (either on the same machine or distributed across a cluster or maybe even a grid), you might have the need to be able to share data. Of course this brings with it a host of other problems like memory safety, synchronization and so on.
Anonymous
Thanks for answering M. But , can't i use shared memory between threads to send some data in string or json to another thread. Or this can be used only to send very heavy data like videos ...
Threads already live in the same memory space. So I dont know what you mean by using shared memory between threads. This is done for you by the OS and you dont have to do anything extra. Shared memory is usually used to communicate between processes on a system.
Whistleblower
Actually I'm working on processor and i was implementing mqtt . So to transfer the subscribed data to publisher i wanted to use shared memory. But, at the same time i was doubtful about it that whether it could be a good soln or it will create problems for me in future.
Anonymous
Exactly! It can be used with threads as well. But i just wanted to know about the scenarios and the design model where i can use shared memory concept .
I am not sure if you understood my post above yours. Threads dont need to use shared memory IPC mechanism. They already share the memory allocated for the process that they are a part of. As to where shared memory can be used, here is an example. A SQL Server uses shared memory with SQL clients running on the same machine because it makes communication between the client and the server easy. It avoids the overhead of TCP/IP connections.
Anonymous
Actually I'm working on processor and i was implementing mqtt . So to transfer the subscribed data to publisher i wanted to use shared memory. But, at the same time i was doubtful about it that whether it could be a good soln or it will create problems for me in future.
Publisher and subscribers can be a good use case for shared memory in your case provided you have the necessary synchronization mechanisms. I hope you are not writing a generic library. But most existing implementations separate publishers and subscribers from the actual publish queue implementation. Publishers and subscribers register with the publish-queue. There are 3 different processes here and instead of using shared memory, they use sockets for IPC. This has the advantage of decoupling.
Yasas
arguments?
I prefer clion
Yasas
👍
Lol,you like it too?
Rberto
Lol,you like it too?
nope, I use vim.
Yasas
nope, I use vim.
It's for advanced users
Yasas
Hard to use
@Infolinux 🖖🏻
Hi
@Infolinux 🖖🏻
#include <stdio.h> int main() { int i; char VarNome[2]; for (i = 0; i <= 2; i++) { printf ("INFORME O NOME: "); scanf ("%s", &VarNome[i]); } for (i = 0; i <= 2; i++) { printf ("NOME=%s\n",VarNome[i]); } return 0; }
@Infolinux 🖖🏻
-----
@Infolinux 🖖🏻
Return:
@Infolinux 🖖🏻
/tmp/ZpzYXxEfpm.o INFORME O NOME: aaa INFORME O NOME: bbb INFORME O NOME: ccc Segmentation fault
@Infolinux 🖖🏻
Any Idea?
Steven
change to i<2
@Infolinux 🖖🏻
This: char VarNome[2][50];
@Infolinux 🖖🏻
Tks
@Infolinux 🖖🏻
Hermann
is possible convert pointer to std::vector?
olli
is possible convert pointer to std::vector?
no, only the other way around since std::vector owns the memory of its elements
Hermann
okk
Hermann
thanks
Pavel
is possible convert pointer to std::vector?
No, but check out std::span https://en.cppreference.com/w/cpp/container/span Maybe it is something that can be helpful in your case
Anonymous
hi
Anonymous
i have question
Anonymous
AT-HOME: (40%) I. Copy your code from sphereVolume_lab.c to sphereVolume_home.c and upgrade the program sphereVolume_home.c so that it prompts the user to enter the radius of the sphere. Execution and Output Example: Please enter the radius of the sphere (in m): 8.68 Volume of a sphere with a 8.68-meter radius is: 2739.35
Anonymous
how to write program?
Anonymous
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void){ #define PI 3.141592653589793 int r = 10; float vol = (4.0f/3.0f) * PI * (r * r * r); printf("Please enter the radius of the sphere (in m): ",vol); scanf("% \n",vol); printf("Volume of a sphere with a float radius is: %.2f \n", vol); return 0;} how to fix it out?? i need urgernt help! thank you !
Anonymous
some one can help me? thank you!
Vlad
how to write program?
https://en.cppreference.com/w/cpp/io/c/fscanf
Vlad
Here's scanf format
Vlad
You pass right format string and a pointer to your variable/variables
Vlad
In your case it would be: float var; scanf("%f", &var);
Sam
1 . Define a structure of employee having data members name , address, age and salary . Take the data for n employees in an array and find the average salary.
Sam
2. Write a program to read the name,address, and salary of 5 employees using array of structure. Display information of each employee in alphabetical order of their name
Sam
Can anyone give the answers plz
Sam
C language
Sam
I tried but couldn't solve
olli
what have you done so far? where is your code?
Sachin
what have you done so far? where is your code?
Why we don't use gets function
Golden Age Of
I tried but couldn't solve
Describe exactly the probl then
Sachin
?
Sam
Why we don't use gets function
She is asking only to use structure and array🤷‍♂️
olli
Why we don't use gets function
gets is considered unsafe because it provides no means to prevent buffer overflows and hence got removed from C++14. If you write code using gets there is a way to 'exploit' it.
Sachin
Can u explain it more
olli
What is buffer overflow
https://en.wikipedia.org/wiki/Buffer_overflow Writing data beyond a buffer's boundaries. There is no way to prevent gets from writing more than 10 bytes. #include <stdio.h> #include <stdio.h> int main() { char Buffer[10]; gets(Buffer); printf("%s\n", Buffer); return 0; }