Questions tagged as 'c'

2
answers

How to format strings and store them in a dynamic vector

In several parts of my code I just need to use bash commands to run programs on Ubuntu. To do this, format the command using sprintf and then run it with the system function. Ex: sprintf(sprintfoutput, "makeblastdb -in %s -dbtype prot -out...
asked by 30.06.2018 / 03:00
2
answers

Is it recommended to use memset before strncpy?

Normally when we want to copy the contents of a given string into another string we can use the strncat or strncpy functions. Using strncat The use of strncat to copy strings is kind of "wrong", as this functio...
asked by 19.07.2018 / 20:48
1
answer

What is the difference between% d and% i in printf and scanf, in C language? [duplicate]

What is the difference between% d and% i in printf and scanf in the C language?     
asked by 18.09.2018 / 19:47
1
answer

Using the switch function in C ++ [duplicate]

The function switch and I do not know what I'm doing wrong I want to put the name marcos ai appear "marks and legal" and put murilo "murilo e bacana". I'm doing this: #include <stdio.h> #include <conio.h> int...
asked by 10.09.2018 / 00:54
2
answers

Unexpected result

I want to divide two integers and result in a floating point value. The following code works normally: #include <stdio.h> float divInts(int x, int y) { return((float)x/y); } void main() { printf("%f",divInts(50,3)); } But...
asked by 07.09.2018 / 21:10
3
answers

Marathon Problem: Calculator (Level 2)

This problem seems very simple, however my code does not submit in any way because of an error with some random input. The program that manages the submission of the question gives me some tips:    Check the following points:       Remem...
asked by 25.10.2014 / 20:32
2
answers

Compiling doubt in C / C ++

I started to study about compilation of multiple files and I had a question. When we create a new header, we have to create another file with the implementation of the prototypes contained in the header, create the object and compile everything...
asked by 08.06.2015 / 17:23
1
answer

How to print the binary representation of a character?

I need to get the binary representation of the characters of a string . I can do the hexadecimal representation with the printf itself using %x . Something like: void imprime_hex(char *input) { for(int i = 0; i < str...
asked by 26.03.2018 / 23:05
1
answer

Problem with function pow ()

Can anyone tell me why the following code does not compile? #include <math.h> double f(double x){ return (x - (pow(2,x))); }     
asked by 27.03.2018 / 02:32
2
answers

How to read a random amount of integers in C?

I need to create a way to read integers in the same input, and the amount of integers entered is random every time the program is executed. I tried to perform the following algorithm: #include <stdio.h> #include <stdlib.h> int...
asked by 09.04.2014 / 19:58