Posts by gfleck • 757 points
23 posts
-
9
votes2
answers562
viewsQ: Why assign NULL on a pointer after a free?
I see in many codes assign NULL on a pointer just after a free, guy: free(p); p = NULL; What good would that do?
-
2
votes4
answers2635
viewsA: How to Delete File or Folder in C Language
On Linux you need to use the function remove. #include <stdio.h> int main() { remove("caminho completo do arquivo ex. /home/user/arquivo.txt"); return 0; } Refer to the function manual remove.…
-
0
votes2
answers1119
viewsA: How to compare part of strings in C?
Yes, it is possible. You will need to use the function memcmp. Example: #include <stdio.h> #include <string.h> int main () { char buffer1[] = "DWgaOtP12df0"; char buffer2[] =…
-
2
votes2
answers303
viewsA: Giving "Segmentation fault" when I try to open C files
Your problem is related to memory allocation in C, Voce is inserting data in pointer char *file1char not allocated, only declared. Replace the declaration char *file1char for char file1char[1024],…
-
2
votes1
answer66
viewsA: Program without SIGINT signal interruption
A very simple implementation of how to capture SIGINT (Ctrl+c) would be like this: #include <stdio.h> #include <unistd.h> #include <signal.h> void sigHandler(int sig) {…
-
4
votes2
answers350
viewsA: Why is it necessary to close file?
The close() in any programming language and operating system is basically used to: If the operating system has limited resources, for example number of files opened on embedded system processors,…
-
1
votes1
answer31
viewsA: Installing email in my debian 8
You can use the Postfix. To get a general idea of what he makes it access HERE Official page of the project HERE And HERE has a tutorial that the Magichat user has indicated for his version of…
-
2
votes1
answer193
views -
1
votes2
answers68
viewsA: C - Problems with printing
There is a lot, but A lot wrong with your code. I would have to do it almost totally. It’s totally based on the patterns XGH. I point here the three Achilles tendons that are causing the date and…
-
3
votes1
answer390
viewsA: How to create a Script inside a program in the terminal?
I understand your question, but in my opinion your approach is wrong. I can not see your image and also Oce did not quote the programming language, but this was already a doubt of mine and I will…
-
4
votes1
answer842
viewsA: What is and what is the sockaddr_in structure for?
In short, it is this structure that deals with network addresses. struct sockaddr_in { short sin_family; unsigned short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; This particular one is…
-
1
votes1
answer83
viewsA: How to update Apache2 on Dedian 9 (Stretch)?
Type in your terminal as ROOT: apt update apt upgrade Or if you only want to update apache see packages that need to be updated on your system with the command apt list --upgradable and then install…
-
12
votes2
answers3359
viewsA: Difference between "~" tilde and "/" bar at linux prompt?
The character ~ remit the folder home user. For example if you type cd ~ in the terminal, the command will take you to the home folder of the user that is running this command. The / refers to the…
-
3
votes3
answers141
viewsA: Isolate processor to run only my program
Regarding GNU/Linux operating systems, there are ways to do this yes, basically Voce will have to use the cpuset. Example: $ mkdir /cpuset $ mount -t cpuset none /cpuset/ $ cd /cpuset $ mkdir sys #…
-
0
votes1
answer135
viewsA: Pressing keys in the terminal
There are keys and keys. You cannot read (through a scanf) for example the combination of keys A and B pressed at the same time, as it is not a character, it simply does not exist AB. To use some…
-
1
votes3
answers16313
viewsA: Comparison of char in C
If you do this if how it works? if(atual->letra == 'a' || atual->letra == 'e' || atual->letra == 'i' || atual->letra == 'o' || atual->letra == 'u'){ ... ... ... }…
-
1
votes1
answer83
viewsA: C++: Compile using Batch
There is already a tool for this and several other automation of compilations. The tool is called make and is widely used in the GNU/Linux world. I advise following this tutorial to learn the basics…
-
0
votes1
answer306
viewsA: Problems with header in. h
Replace in in.h all the u_long, u_char and u_short for unsigned long, unsigned char and unsigned short respectively. The other error concerns the header missing netdb.h that has not installed in…
-
0
votes1
answer84
viewsA: Need pull-down resistor
Look I can not comment because I have to have 50 points, and also this is not the answer, but I advise you to post your doubt here that has a more directed staff: https://arduino.stackexchange.com/…
-
0
votes1
answer206
viewsA: How do I generate a binary executable?
You can use standard C functions: fopen, fwrite, fread and fclose using the flags wb to write or rb to read binary data. The mode string can also include the Letter 'b' either as a last Character or…
-
0
votes1
answer127
viewsA: Matrix error as function parameter
When we pass a matrix to a function we are actually passing the memory address of the first element of the matrix, so this passing a parameter by reference and the values will be changed within the…
-
-1
votes1
answer112
viewsA: How to debug a C/C++ application remotely using ECLIPSE, different operating systems?
Consult this documentation, I believe it will give you a north. Remote debugging serves exactly this purpose. The first paragraph already explains. If you are trying to debug a program running on a…
-
1
votes1
answer100
views