Questions tagged as 'printf'

1
answer

Concatenate string with int in printf

You can do this in C: int MAX = 30; printf("\n| %".MAX."s | %8s | %8s |", "Nome", "Salario", "Idade"); printf("\n| %".MAX."s | %8.2f | %8d |", pessoa[i].nome, pessoa[i].salario, pessoa[i].idade); Note the MAX between strings to de...
asked by 06.11.2014 / 00:32
2
answers

C printf error

The error in question in a flag that should supposedly be correct, follow the code below: #include <stdio.h> #include <string.h> int main() { char var[50]=" Write Once Bug Everywere "; int i,cont=0; for (i = 0; i < 50; i++...
asked by 18.02.2017 / 01:22
1
answer

Printing a vector ... Differences between C ++ and C ... Where did I go wrong?

I have problems in vector printing of structs in C, in C ++ it worked ... First I will show the C version with problems (in the execution since it compiles without errors) CACHE cache = createCache(descricao); //chamada da main printaCache...
asked by 18.11.2016 / 05:08
1
answer

How to set the number of exponent numbers in scientific notation in C ++

My code is giving the error in the presentation of the scientific number, because it always appears with 3 decimal places being needed only. #include <stdio.h> int main(){ float num=0.0; scanf("%f",&num); printf("%.4e",...
asked by 05.09.2018 / 20:23
3
answers

Printf does not print within the while

The purpose of the code is to print the values from linked lists.   Example of how the list is:    L-> [3] -> [4] -> [5] -> X, should print 3, 4, 5. However it does not. typedef struct lligada { int valor; struct lligada *prox; } *LIn...
asked by 24.04.2018 / 13:03
1
answer

How can I print the fifth part of a real number?

How could I print the fifth (index 4 from the dot) part of a real number without using libraries or a "complex" code for opening chapters. Make a program that reads a real number, and print the fifth part of that number.
asked by 13.10.2017 / 14:00
1
answer

How does the buffer work using printf and scanf?

Using printf , when I do: printf("\n\tQualquer coisa\n"); It inserts this first into a buffer and then prints to the screen (standard output)? Using scanf with the format %c , it captures the character-to-character buf...
asked by 07.11.2014 / 13:48
2
answers

Why do even numbers do not have the same output as odd numbers?

I made a program that asks the user for a number that will serve as maximum value. And then the program shows the odd and even numbers from 0 to that number. I used printf to have an output like this: Os números pares são os seguintes:...
asked by 28.10.2017 / 11:48
2
answers

printf does not show expected value

I'm having difficulty displaying some printf , for example: printf("\nDigite as horas : %d"); And at the time of displaying the message, it appears with a side number, for example:    Enter the hours: 89676 What's wrong with th...
asked by 11.04.2015 / 02:20
1
answer

Principle value of a struct through pointers

I want to print the "attribute" name of a struct of type "Person", however the printf returns (null) but I declare the name of the struct. Here is the code below: typedef struct pessoa{ char *nome; struct pessoa *pai; struct pessoa *mae...
asked by 19.05.2018 / 04:46