Posts by zentrunix • 5,511 points
272 posts
-
1
votes2
answers91
viewsA: Project linkage problem with more than one source file
Your build command is wrong: gcc ex09.c ### BAD!!! It must be so: gcc -o ex09 ex09.c funcao1.c ### GOOD :)
-
4
votes2
answers2311
viewsA: How do I create a C Makefile
This is all wrong main: ex09.o funcao1.o gcc -c ex09.o funcao1.o -o main ### BAD because "-c" and "-o" at the same doesn’t make sense: "-c" says to only compile and not create the executable,…
-
1
votes3
answers23806
viewsA: Size of a String
An array of characters ("char vector") nay is known as "string". It is an array of characters... This array of characters (char ch[4]) occupies 4 bytes or 4 memory positions in today’s computers…
-
2
votes2
answers176
viewsA: Why am I getting Segmentation fault dynamic matrix?
In short: this line float **matriz = malloc(tamanho * sizeof(float)); // BAD it’s wrong, it should be like this: float **matriz = malloc(tamanho * sizeof(float*)); // GOOD One thing most beginners…
-
1
votes2
answers279
viewsA: Problem with Struct and Function in C
There are (at least) 2 errors. The first is the use of "%c" when it should be "%s". The second is the statement of the structure: struct FichaCarro { char fabricante[15]; char modelo[15]; char…
-
2
votes1
answer59
viewsA: Problem reading file
Assuming this statement: float distancias[N_cidades][N_cidades]; That is wrong: fscanf(arv,"%d",&distancias[i][j]); // ERRADO! This is the right way to read floats:…
-
0
votes1
answer35
viewsA: Parameters in the Signals Handler
Use a global variable. I don’t think there’s any other way.
-
1
votes1
answer143
viewsA: Problem printing string array of a pointer and repetition of the main C++ method
There are several problems in your code, I will focus only on one of them. Here el = new Elemento(itens,num); You are creating an anonymous object of the Element type, and in the Element object…
-
4
votes3
answers4855
viewsA: Usefulness of #pragma
Pragmas are "directives" for the compiler, which affect the compilation process. Pragma "Once" is usually (always ?) used at the beginning of a file . h that will be included in other source files .…
-
0
votes3
answers399
views -
0
votes2
answers108
viewsA: (C++) Deck: Differences between position access types
mideque[i]: access the element without checking the validity of the index mideque.at(i): access the element by checking the validity of the index…
-
6
votes1
answer219
viewsA: Start structure pointer with an address?
Can: p = (pessoa*)1234; Now, you gotta know what you’re gonna do with it...
-
13
votes3
answers68185
viewsA: What is the difference between endpoint and API?
Endpoint and API have absolutely nothing in common. Endpoint, in addition to the generic meaning of "something that’s at the tips", is most used today in data communication, and refers to two "tips"…
-
1
votes3
answers611
viewsA: Incorrect counting in electronic voting program
Its "vote" function is recursive, i.e., it is called again internally! Recursive functions have their usefulness, but are used relatively little. In your case, at each recursive call the count…
-
1
votes2
answers4477
viewsA: make: g++: Command not found make: Error 127
Type in the terninal sudo apt-get -y install build-essential keystroke ENTER You may need to install g++ separately sudo apt-get -y install g++ keystroke ENTER You may need to install make…
-
0
votes1
answer43
viewsA: Error setsid function relative to ppid
You are running your program on a graphical desktop (GNOME, KDE, etc). I tested it on GNOME and it really happens as you said. If you run on console (CTRL+ALT+Fn) the pid Parent of the daemon will…
-
1
votes1
answer45
viewsA: Capture Started Strings with %t and %u
I don’t know Arduino, but by your explanation and by the code you showed the logic could be more or less like this: void recebeir() { char temp[5], umid[5]; char valorlido = Serial.read(); if…
-
2
votes1
answer247
viewsA: Error in conversion from infix to posixed notation
Whenever you access the top of the stack you need to check if the top of the stack is valid. For example, for the expression "3+7", with this change below there is no segmentation error. case '+':…
-
0
votes2
answers198
viewsA: Windows Blibiotecas to use in Assembly
Programming for the native Windows GUI (Win32) is a fairly extensive subject. To study seriously I recommend following a book, such as the classic "Programming in Windows" by Charles Petzold.…
-
1
votes4
answers2799
viewsA: String reading with two or more names
The general rule is: don’t try to do anything complicated with scanf. The purpose of the scanf function is to work with structured data, normally read from a file. To work with interactive data…
-
1
votes2
answers477
views -
0
votes3
answers541
viewsA: Bash - Save errors in a variable
Why do you "need" to put in a variable ? I find it questionable, but anyway... It seems the best way is to follow this suggestion of…
-
2
votes1
answer41
viewsA: script called once but turns two processes
This command back & creates a process in the background. Even after the original script has finished a copy of it is running in the background, because of the "&" above.…
-
0
votes2
answers1638
viewsA: How to test if a host port is open?
The only way to know is to try to open a connection. If the port is not open your application receives an immediate response (error 1225 on Windows and 111 on Linux, corresponding to a TCP RST…
-
1
votes1
answer79
viewsA: "Undefined Symbols" error when compiling project
The source file where the "knapsack" function was set was not included in the build. Or, if it is a function provided by a library, this library must be provided in link-editing. How to do ? It…
-
4
votes2
answers137
viewsA: Is it possible that a class attribute is the class itself?
In C++ it is possible that an attribute of a class is the class itself? NAY. In C++ it is possible that an attribute of a class is A POINTER to the class itself? YES. Detail: in C++ a C structure is…
-
0
votes3
answers8881
viewsA: How to import functions from another C file?
Simple example of file organization of a project in the C language. (Function names are only illustrative, not a scheme to be followed!) File .... /game/main. c #include "rg/rg.h" // regras de…
-
3
votes1
answer97
viewsA: Matrix initialization error
The error message is very clear: array indexes need to be integer. You’re using float! This is wrong.
-
3
votes1
answer704
viewsA: Global variable C++
Overall your program is right, with the following reservations: these functions bool cheiaLista(ListaVend); // BAD bool vaziaLista(ListaVend); // BAD void showLista(ListaVend); // BAD should be…
-
1
votes1
answer2122
viewsA: How to create a driver to make my own usb mouse with PIC?
Driver development is a highly specialized area. So casually it is impossible to create a driver, you will need to study the subject thoroughly in specialized books, and try a lot. Microsoft…
-
6
votes3
answers4376
viewsA: What is the purpose of the return of the main function and the importance of this function?
In the language C the function return value main is passed to the operating system, and can be tested by the parent process. A concrete example: in Windows, when you work in a "DOS window", this…
-
4
votes1
answer79
viewsA: How does the data types after constant work in C?
This example shown in the question does not serve any useful purpose other than to demonstrate the directive #define. The result of this is this: #define foo unsigned int #define i typedef // bla…
-
2
votes2
answers584
viewsA: Python socket keeps open even using Close
Generic response: the client has to do its part, when the result of the recv in client for 0 this means that the server will no longer respond, so it is the responsibility of the client to do the…
-
0
votes3
answers336
viewsA: Problem regarding type in function with variable parameters in C
You have to cast the int for double. With this prototype double somaVariaveis(int qtd, ...) this function accepts parameters of any type in place of the 3 dots. In the general case there is no way…
-
2
votes2
answers377
viewsA: How to generate a . of the implementation of a class . cpp without the main function in g++?
g++ -c xxx.cpp This command generates the file xxx.o. To compile, use g++ -o yyy main.cpp xxx.o. This command compiles main.cpp and link-edits with xxx.o, creating the executable yyy.…
-
1
votes1
answer345
viewsA: Publish Visual Studio does not connect to remote computer (Web Deploy)
I don’t know any of that there (web deploy etc), but this message "Destination not Reachable" is typical network problem... ping, tracert, try to access the Web Deploy via telnet, make a network…
-
0
votes1
answer1172
viewsA: Node.js receiving GET command
I won’t go into detail about your program, I would have to understand it first, but I will show you a minimal example of a Node.js application. Important: you do not need to "get" to read an http…
-
1
votes1
answer97
viewsA: Conversation error from int to String
this here NAY is transformed into a int in a string, is converting a int in ONE character... just doesn’t make sense temp10= temp6+temp7+temp8+temp9; char temp10=temp10+'0'; here gives segmentation…
-
2
votes2
answers82
viewsA: Conversion of byte array to string when compiling revealing the string in C compiled code
void sendPassword(void) { char arr_code[x]; // x: constante a determinar arr_code[0] = 79; arr_code[1] = 99; // etc // usa arr_code memset(arr_code, 0, x); } This way your "secret code" will not be…
-
3
votes3
answers163
viewsA: "Carry" variables between functions, appears strange character in place?
Change "%c" to "%s". This is the error. Even in the case that is apparently working, it is by chance...
-
1
votes2
answers803
viewsA: Recursive search for files in directories
The command return search function File already does this...and apparently your code is correct. I just reformatted to get more to my liking, but it’s working. #include <sys/types.h> #include…
-
0
votes1
answer1148
viewsA: Bubblesort sorting method with dynamic allocation + pointer
I found it easier to redo the program than explain the mistakes individually... Points to be observed: 1) If you have int* p then *(p + i) is the same thing as p[i]. 2) Comments /* */ do not nest,…
-
2
votes3
answers451
viewsA: Is the Std::map structure in C++ a tree?
The C++ definition does not specify how the implementation should be done. However, the most common implementation seems to be a "red black Tree". Article in Stackoverflow on the subject:…
-
3
votes2
answers2002
viewsA: pass objects as parameters in c++
The problem is the use of the same identifiers for class and variable names. This left the compiler confused... Changing nome for nome_, matricula for matricula_, and senha for senha_ started to…
-
2
votes2
answers425
viewsA: Use delete on allocated objects without new?
You should only use delete for objects allocated with new. Dot.
-
0
votes1
answer1040
viewsA: The server responds with the RST/ACK flag after the client sends the SYN flag
Most likely there is no application waiting for connections on that port on the target server. The fact that "sometimes" the connection is successful indicates that "sometimes" the application in…
-
4
votes7
answers21016
viewsA: What does the term Fallback mean?
Fallback is not, in general, a technical term in computer science. It is used according to its general meaning of "contingency" or "secondary alternative". Rollback is a well-established technical…
terminologyanswered zentrunix 5,511 -
2
votes1
answer937
viewsA: How to compile . cpp codes that have separate interfaces and implementations in g++?
You are not compiling the class implementation... g++ -o gradebook gradebook.cpp main.cpp
-
1
votes3
answers181
viewsA: Use of data type modifiers
One reason is that it is not very practical because the use of more specific types ends up generating many warnings in the compilation. For example: short x; short y, z; // normalmente aqui a…
-
1
votes1
answer40
viewsA: Failure to run loop
The constructor of the User class does nothing, so the setAccounts method is never called...this is the error. Another strange (but not wrong) thing is the statement class User *managment = new…