Posts by Rafael Coelho • 346 points
21 posts
-
1
votes2
answers2874
viewsA: Python, Caesar Cipher, Strings
I made some little suggestions in your code: I changed the repetitions to not use white True (I made two possibilities, receive function and receive) I modularized your generated XML method,…
-
2
votes2
answers7124
viewsA: How to get the directory from the location where a . py file is running?
To get the absolute path: import os dir_path = os.path.dirname(os.path.realpath(__file__)) To get the relative path: import os cwd = os.getcwd()…
-
3
votes1
answer992
viewsA: How to write a . csv file in Python including file settings?
Yes, it is possible. An example of using the delimiter "," would be: import csv csvfile = "C:\pasta\arquivo.csv" f=open(csvfile,'wb') # abre o arquivo para escrita apagando o conteúdo csv.writer(f,…
-
0
votes1
answer40
viewsA: Error finding equal numbers
I believe this is what you would like: int main(int argc, char** argv) { int m, i, j, cont = 0; int vetor[100], verifica[100]; scanf("%d", &m); if(m != 0) { for(i = 0; i < m; i++) verifica[i]…
canswered Rafael Coelho 346 -
0
votes1
answer146
viewsA: How to create a C function that searches for words in txt files in a predefined directory?
You need to call Strtok the first time before entering the third loop. token = strtok(strget, ""); Inside the third loop, you must call passing NULL as parameter: token = strtok(NULL, "");…
canswered Rafael Coelho 346 -
0
votes1
answer2134
viewsA: How do I pass a struct vector by reference parameter?
int main() { setlocale(LC_ALL,"portuguese"); ENQUETE ler[10]; int i=0,opcao; printf("\n-------------------- ENQUETE IBOPE --------------------\n"); do { menu(); printf("\n Opção: ");…
-
2
votes2
answers495
viewsA: Problems with fwrite in binary file
In C, until you flush the file or close it, what is stored in the buffer is not passed to the actual file. I advise you to open the file for reading, use it and close it. And when you want to write…
-
0
votes2
answers678
viewsA: Convert String to Array - Java/Groovy
I don’t know if this is what you wanted to do, but take a look at the code I generated from your question: public static void main(String[] args) { //teu vetor tem valores null e false (boolean) que…
-
0
votes2
answers830
viewsA: Return and pass structure through a function in C
You can do as @Jonathanbarbosa19 explained by returning the created struct. But you can also pass the reference by parameter. typedef struct funcionarios { int cod_func; int cod_cargo; char…
-
0
votes2
answers1020
viewsA: How to pass an integer file to a C vector?
Follow your changed code with some suggestions: void quicksort(int *P, int tam); void mergesort(int p1[],int i, int j); void merge(int p2[],int i1,int j1,int i2,int j2); void mergesort(int p1[],int…
-
1
votes1
answer66
viewsA: Problems in String and Case
I made some suggestions in your code: int main() { int opcao, opcao2; //nao use a mesma variavel para os dois switchs cliente cadastro[100]; int i; char sair; //precisa envolver todo este código em…
-
1
votes3
answers69
viewsA: How could I read a 3-digit value and print them on the screen reversed in C?
Use the sprintf function: #include <stdio.h> int main() { int someInt = 368; char str[3]; sprintf(str, "%d", someInt); printf("%c%c%c", str[2], str[1], str[0]); return 0; }…
-
1
votes2
answers1339
viewsA: Remove first element from a simple chained list
You can use the logical (boolean) type of the stdbool. h library to return true if the removal has worked. And the code is more understandable if you have the representation of a node. typedef…
-
0
votes2
answers68
viewsA: Vector by Parameter in C
When working with vectors, you should not put & to pass the memory address because it already receives this way (only with vectors). Put the rest of the code because you are passing a vector…
-
1
votes1
answer238
viewsA: Data does not persist on switch case
The main problem is the definition of the vector within do-while. This causes the vector to be initialized every time the repetition occurs. Option 1: main(){ int opcao, contUser = 0; do{ Menu();…
-
0
votes2
answers299
viewsA: Inserting elements in a dynamic list
Follow your code with some changes: created a struct for the list, having a pointer to the first Elem of the list I modified an excerpt of your insertion because he made wrong notes I created a…
-
1
votes2
answers887
viewsA: Split double chained list with head
Follow your readjusted code from a doubly chained list. Just explain to me how you want to split the list. Based on what? #include <inttypes.h> #include <stdio.h> #include…
canswered Rafael Coelho 346 -
0
votes2
answers199
viewsA: How to monitor a C code on Linux
You can use the commands @cemdorst specified and run it as if it were in the terminal via the popen function. Here is an example for the PID 1234 process: int main() { FILE *stream= popen("top -p…
-
1
votes3
answers454
viewsA: Loop of repetition in C
In this case, the ideal is to use do-while because you want to show the menu before asking for the user option: int opcao = 0; do { printf("\n0 - SAIR"); printf("\n1 - Op 1"); ... scanf("%d",…
-
1
votes1
answer1026
viewsA: Printing binary tree graphically in C
Looking quickly, I found the following errors: The functions planta_tree and inserts should be void because one already receives a pointer and the variable to which it points already modifies the…
-
2
votes2
answers622
viewsA: What is the /** code for in the java language?
Complementing, follow some tags: {@code} all text inside keys is not interpreted, including text marked HTML and Java tags {@docRoot} contains the root directory of the generated documentation…
javaanswered Rafael Coelho 346