Questions tagged as 'c'

3
answers

Storing Variables in .txt Files

I'm a beginner in C and I'm looking to study how to get my program set up every time it runs. It seems to me a very important thing, but I found little material. For example, "remember" which was the last DIR my program was "reading" whe...
asked by 07.10.2016 / 15:21
2
answers

How should you correctly terminate these variables without having a chance of memory leak?

What is the correct way to use free() in this case, where ls_options will contain several ls_buffer_send ? char **ls_options = (char**) malloc (200*sizeof(char)); char *ls_buffer_send = (char*) malloc (350*sizeof(char));  ...
asked by 27.07.2016 / 20:10
1
answer

Program does not compile with miscellaneous errors

What is wrong here? I can not see the error. #include <stdio.h> void Main(void) { int a = 9; int b = 3; int c = 0; int *p = &b; c = a/*p; printf("%d \n", c); }     
asked by 08.12.2014 / 15:11
2
answers

String of characters within the scanf. Why and how does scanf works ("Day% d", & day);

Problem I was making a code that would be to read a string and then an integer value: int dia, h, m, s; char dp; //Dois pontos. scanf("Dia %d",&dia); //Inicio do evento. ... I thought about creating a string for the us...
asked by 13.10.2014 / 13:00
1
answer

Why use pointers as function parameters?

I already have some knowledge about pointer, but I wanted to understand why in most cases people use pointers as parameters in functions. I'm currently studying algorithms through the GeeksforGeeks portal, which I find very cool because it...
asked by 18.05.2017 / 13:46
3
answers

Limit size of a String?

I declare char pl1[10], pl2[10]; And I did the following: printf("Nome do Player1: "); scanf("%10s", &pl1); printf("Nome do Player2: "); scanf("%10s", &pl2); Thinking he would read only the first 10 characters that the user typ...
asked by 12.06.2015 / 16:31
3
answers

"Carrying" variables between functions, does strange character appear in place?

In the main fault function when I print a char , it appears a strange code resembling a hex: But when I print the same char in another function it appears normal. char tempA[100] = "1111"; int main () { strcpy(tempA , "1...
asked by 16.09.2016 / 15:04
1
answer

Accept uppercase and lowercase character

I'm making a rough draft just to train if and else that will be a subject in my next college class. I want to get there and at least already have a base of what the teacher will teach. My question is as follows. When I ask th...
asked by 02.09.2018 / 19:43
1
answer

Change value of a vector in a function

How do I? I'm trying: #include <stdio.h> #include <stdlib.h> int changeMap(char mp[], int x, int y){ mp[x-1][y-1] = 'X'; return 0; } int main(){ char map[][1] = "gabriel"; printf("%c", map[0][0]); changeMap(map, 1,...
asked by 17.12.2014 / 08:18
2
answers

Warnings interfere with the program?

I am performing the following exercise: Afterafewattempts,Icameupwiththefollowingfinalcode:intproximo_da_media(int*vec,intdim){inti,*pos;floatmedia,soma=0,diferenca;pos=vec;//inicializarponteirofor(i=0;i<dim;i++)soma+=*(vec+i);//fazasomadeto...
asked by 31.03.2018 / 19:16