Posts by Brumazzi DB • 4,345 points
175 posts
-
1
votes3
answers1650
viewsA: How to highlight text (change color) in ANSI C
Depending on the OS you use, you have different implementations. Systems that in MS-DOS, have the library conio.h, meanwhile systems Unix owns the curses.h. Another way is to write directly the…
canswered Brumazzi DB 4,345 -
3
votes3
answers1883
viewsA: How to Create and read ". conf" files in C, for linux environment?
There are several ways to create configuration files. The configuration files in /etc has its own structure for the user to read. If you just want to store the values of your variables in the files,…
-
1
votes1
answer99
viewsA: Print multiple matrices separately
If you want to print 3 or more, put them together. int matriz[3][100][100]; int x,y,z; for(x=0; x<3; x++) for(y=0; y<100; y++) for(z=0; z<100; z++;){ printf("entre o valor da matriz %x,…
-
9
votes3
answers4855
viewsQ: Usefulness of #pragma
Several C/C++ codes have the word pragma. Depending on the way it is implemented it has a different function. #pragma Once #pragma pack() #pragma comment(xx, "") For what purpose the pragma was…
-
0
votes1
answer110
viewsA: Error in removing c++
A small observation, is that your methods have parameters, but still, values are read within them. It is not correct to use parameter variables to store value (except if returning values by…
c++answered Brumazzi DB 4,345 -
1
votes1
answer28
viewsA: Gtkliststore, invalid string type
Fixed the problem, the method gtk_list_store_set was trying to store an empty string in field 0 of the list. gtk_list_store_set(lp->store, &iter, 0, prod, 1,…
-
1
votes1
answer28
viewsQ: Gtkliststore, invalid string type
The code is giving invalid format string error when passing the Gtkcomboboxtext for a Gtkliststore. Error: (System:18726): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()…
-
1
votes1
answer163
viewsA: Keep connection active after a POST request
To save the data, it is necessary to go up a session, for the server to save the data in the user session, the header sent to the server must contain the session data. Cookie:…
-
8
votes1
answer1466
viewsQ: Difference between GCC Clang
The systems based on Unix (a large majority), usually use the GCC, to compile the files in C, but I also possessed the Clang for the same purpose. There is difference when compiling some project…
-
0
votes2
answers292
viewsA: How to reuse a pthreads?
The function pthread_exit, expects all the Threads shut down to terminate the system. Then it would be the same thing as using a exit. But if you want to reuse threads, you can use a counter to wait…
-
0
votes1
answer100
viewsA: Socket C ansi header Post
Assuming you want to access a local server, Apache is active and a connection is made through Socket, after connecting to the server, it is necessary to pass a Header(Header). main: const int PORT =…
-
2
votes1
answer164
viewsA: Python Shell cannot run a module with more than one while loop
The run that when you put: def play(): playing = True The interpreter created playing as a local variable, so even if you change the value within play the playing global will remain False.…
python-3.xanswered Brumazzi DB 4,345 -
5
votes1
answer119
viewsA: Program error C, vector store;
In C doesn’t have the library iostream, then use only the stdio.h. The statement of entrevistados is wrong, as is a struct, should state how struct infoPessoa entrevistados[tamanho]; The repetition…
canswered Brumazzi DB 4,345 -
2
votes1
answer124
viewsA: Help in struct C, unable to feed
First, in his for, the cont shouldn’t be <= to 5 and yes < that 5. because every vector in C goes from 0 to N-1. The methods have different types of reading, the gets works the same as…
-
0
votes2
answers57
viewsA: Create dynamic structures based on a text file
The characters in the files are the same as in the table Ascii, that is, it is a char with the value of 0 to 255, as well as the permitted values for a char in C. In case you want to take a number…
-
0
votes3
answers5495
viewsA: Display the values of the c++ vector on the screen
Your error is initially in increment of i. The i++ should be at the end of the structure. case 1: system("cls"); cout<<"Produto: "; cin>>produto[i]; cout<<"\nCusto: ";…
-
3
votes1
answer88
viewsQ: Influence of ":" in Ruby
The Framework data validation parameters Ruby on Rails, use values with : before and after the word. validates :terms_of_service, acceptance: { accept: true, message: 'Mensagem de Validação' }…
-
1
votes3
answers116
viewsA: Why can’t Javascript find a page tag?
What happens in your code is that you are capturing the name of its bud, before it was created in the tree GIFT. To solve this, yours Tag script should be below the button. <button id="a"…
javascriptanswered Brumazzi DB 4,345 -
3
votes1
answer46
viewsA: Parole bugging in C
The value of your choice is always 1 because of the first condition if. For you do not make the comparison, but an assignment. if (escolha = 1) // atribui 1 em escolha So he always enters this…
canswered Brumazzi DB 4,345 -
15
votes2
answers6768
viewsQ: What is, and how it works, a Etag
I have been making socket requests to my Apache server in order to create a prototype of Framework, and for each different file that was accessed, returned a Etag in the header. What good is a Etag?…
-
0
votes1
answer243
viewsA: Infinite loop in exercise using classes
The error is in the class Engine. while current_scene != 'last_scene': next_scene_name = current_scene.enter() current_scene = self.scene_map.next_scene(next_scene_name) current_scene is an object,…
-
1
votes1
answer316
viewsA: string to object in javascript
The value in editableObj.innerHTML does not return an object, whenever a value of HTML through the innerHTML, the return is always a string. To confirm this type…
-
1
votes2
answers254
viewsA: Unzipping files with space in name
It is possible, for this, you have to find a way to separate your files. As the division of your files will be by line break (because of ls), we will use it to divide your Strings. zfiles=$(ls…
-
2
votes4
answers6903
viewsA: Generate random numbers that do not repeat
You should register the numbers that have already left and generate another case out it. For this, it is good to store the numbers in a list. Available code Here. int n; Stack *list = NULL; Stack…
-
1
votes2
answers1609
viewsA: Random distribution in lists with python
You can use the random to draw the value and the new position to be inserted. If the position is different from 0, try again. import random as r li = [None, None, 65123, 2223, 4536, None, None,…
-
0
votes1
answer927
viewsA: Make a function that receives a matrix A(10,10) and returns a vector with the sum of each of the lines of A
First your method should receive the matrix, then in your declaration it should be. int *soma(int **matriz){ /*...*/ } int * says his method will return a vector, and int ** says that the parameter…
-
3
votes1
answer727
viewsA: Countdown time
The best way to make an accountant in games is by using Threads, so it will be possible to count the time without the interference of Frames of the game (FPS). void time_decrement(void…
-
0
votes2
answers1766
viewsA: Defined function not defined
Usually when you put this within a method in Javascript, the interpreter inserts an attribute within the method. To modify the size as you want, you must pass the object as a parameter inside your…
-
1
votes2
answers1740
viewsA: Query methods, classes and attributes in the C language
Language C does not have Classes and/or modules like Python, Java, or C++. The closest to that are structs that resemble the dict python. Regarding the variables, C has int (inteiro),char…
-
3
votes2
answers481
viewsA: Keep variable value in python function
Python does not have a method of declaring static variables, but there are some means and do this. def static_num(): # método com variável estática static_num.x += 1 # incremento return static_num.x…
pythonanswered Brumazzi DB 4,345 -
1
votes1
answer73
viewsA: Doubt about arrays and pointer
As in C it is possible to declare variables anywhere in the code, you can request the value and then declare its vectors. Example: int vec_len; scanf("%d", &vec_len); int…
canswered Brumazzi DB 4,345 -
0
votes2
answers3966
viewsA: I need to put a button next to an input of type select, how to do?
Assuming your button is outside the div, it should be taken into account that the div owns the display: block, This makes it have a line just for her, so it should change to display: inline-block or…
-
1
votes1
answer234
viewsA: Integrate C and C++
Cannot compile a code C++ in C, but it is possible to compile a code C in C++. main. c: #include <stdio.h> extern int sum(int x, int y); int main(int argc, char **argv){ printf("O código da:…
-
1
votes1
answer145
viewsA: C++ run secondary program, only if the command is typed
If the parameter is directed to the executable you are trying to open it would be: char command[512]; char arg[64]; scanf("%s", arg); sprintf(command, "F:\\AI\\iapt2.exe %s", arg); // executa…
c++answered Brumazzi DB 4,345 -
0
votes1
answer1897
viewsA: How to use pointer and vector in a single struct in C?
Starting with your method ler, if it receives a vector, then the data type will be: void ler(struct RgAluno Aluno[]) //ou void ler(struct RgAluno *Aluno) The way you stated it says the method has d…
-
1
votes1
answer80
viewsA: The function writes to the file in txt. I need to sum but the vector is as char
First you have higher values than 255 so you can’t use a vector char its vector must be a int. int vetor[50]; To make the sum, use a for within the while. int line; while(!feof(arq)){ //... line =…
canswered Brumazzi DB 4,345 -
3
votes2
answers549
viewsA: Error while reading C file
You missed the format of the reading of fscanf "%d;%d;d%;%d", the % is after the d. The sum if adding the values of the file in a single variable would be for(i = 0; i<4; i++){…
canswered Brumazzi DB 4,345 -
2
votes1
answer667
viewsA: Semaphore and Mutex in C
First my suggestion is to create a 3 PC spaces (or a char 3-space). typedef struct{ char *nome; char status : 2; // 0 - livre | 1 - ocupado // O ": 2" especifica que em status, o valore máximo será…
-
2
votes1
answer793
viewsA: Pointer from struct to struct
Your code error does not happen on the line scanf(" %s", ps->p.name); The problem is further forward in: while(tmp->next != NULL){ tmp = tmp->next; } The content is that tmp->next has…
-
3
votes2
answers345
viewsA: FWRITE function is not writing in binary format in C language
Your file has characters for the following reason. As his struct consists of 4 fields char and a field int, the normal is that the data can be read. The method fwrite writes directly the values of…
-
1
votes2
answers3738
viewsA: How to make one element stay on top of another with :after?
This should solve your problem. The position of .estrutura:after this as relative, and added the top: -32px to move the text up and above the image. .estrutura{ width:10%; height:30%; }…
-
0
votes1
answer34
viewsA: st_gid and I-Node with different values within the stat structure
You redeclared the method stat, and did not assign the value in buf. main. c: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include…
canswered Brumazzi DB 4,345 -
0
votes1
answer75
viewsA: Run ruby script in C
So you have the same problem importing the script. Some methods have become obsolete since version 1.8.0, to run a file in version 2.x.0 just use the method rb_require. ruby_setup();…
-
1
votes1
answer75
viewsQ: Run ruby script in C
The error code when running the script in ruby. file.Rb: #!/usr/bin/env ruby x=1 while x<10 puts "It Work!" x+=1 end main. c: #include <ruby-2.0.0/ruby.h> int main(int argc, char **argv){…
-
2
votes1
answer3825
viewsA: Fix permissions on the linux root
You can sign in as super user with the command su, unlike the sudo, the su authentication as super user (super user password required, not user password). Or sign in direct as super user. "Start…
-
1
votes1
answer290
viewsA: I Can’t Clone a git repository on TFS on my local machine
The pull serves to update the existing data on your machine, to clone the repository you must use the clone: $ git clone <url>.git repo $ cd repo When making changes you must first make the…
gitanswered Brumazzi DB 4,345 -
4
votes2
answers805
viewsA: How to define a global alias in BASH?
You can add these lines to the file /etc/profile, Once the user logs in, the information is loaded. $ sudo vim /etc/profile ou $ sudo nano /etc/profile profile: #... alias tt="php artisan tinker…
-
0
votes1
answer396
viewsA: Know how many elements I have in an array in Arduino
The ideal is to start by clearing any kind of value within the array. int x; // limpa os valores do array for(x=0;x<100;x++){ array[x][0] = 0; array[x][1] = 0; } Then the method for insertion is…
-
20
votes1
answer8743
viewsQ: Python, difference between assert and raise?
I came across a question with the structures raise and assert python. In the code below shows the implementation of structures forcing an error if the number passed is negative. def…
-
0
votes2
answers86
viewsA: Problem with dynamic allocation of bidimencional matrices in C
You are not allocating the values in the right place. The line A[linhasA] = malloc(colunasA * sizeof(int)); causes all values allocated to be in position linhasA so there are no positions [0..n-1]…