Most voted "printf" questions
53 questions
Sort by count of
-
31
votes3
answers13759
viewsDifference between %i and %d
Is there any difference between printf("%d", x); and printf("%i", x);? I know the two return the same result, have some kind of convention adopted to always use the %d?…
-
11
votes3
answers3123
viewsformat ľ%d' expects argument of type ěint', but argument 2 has type ěchar *' - What is it? How to tidy up?
Code: #include <stdio.h> int main(void) { char caractere, *caractere_ptr = &caractere; printf("Caractere: foi alocado %zu byte\n", sizeof(caractere)); printf("Endereço: %d",…
-
8
votes2
answers784
viewsprintf in Java - What is %3d for?
I’m seeing a java arrays exercises, but I can’t understand what the %3d, if it’s a int. for (i=0; i<n; i++) { System.out.printf("a[%d] = %3d b[%d] = %3d\n", i, a[i], i, b[i]); }…
-
7
votes2
answers3921
viewsputs() and printf(), when and which to use?
Data input requests are usually preceded by text indicative of what you wish to receive and usually do not have data to be formatted. If variable data are not being presented in the request text,…
-
6
votes3
answers9114
viewsWhat are the differences between printf, fprintf, sprintf, snprintf, printf_s and fprintf_s?
Researching I noticed that there are several variations of printf, but I did not understand which differences and which to use in a certain circumstance. I would like to know the purpose of each…
-
6
votes2
answers6106
viewsDifference from Cout to printf in C++
I wonder what difference I use in C++ cout and printf, it’s all the same?
-
5
votes1
answer819
viewsHow does "printf()" work?
How the code works behind the function printf() do C? I am aware of what this function does, I want to know how it does.
-
5
votes2
answers10981
viewsConcatenate char variable text in printf
I need to concatenate the name of the person (variable) with a text. Following the logic, it would look like this #include <stdio.h> int main (void){ char nome[6]; printf("Ola! Insira seu…
-
5
votes1
answer210
viewsWhat is the difference between %p and %d in C language?
Which means the memory address that appears with %p and the %d exactly? What’s the difference? int main() { int teste = 10; int *ptr = &teste; printf("%p\n%d",ptr, ptr); return 0; }…
-
3
votes1
answer426
viewsConcatenate string with int in printf
It is possible to 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,…
-
3
votes2
answers721
viewsError in C printf
The error in question in a flag which was supposed to be correct, follows the code below: #include <stdio.h> #include <string.h> int main() { char var[50]=" Write Once Bug Everywere ";…
-
3
votes2
answers1022
viewsError: incompatible type for argument 1 of 'printf'
I have this activity, exercise, where is to display the largest number, but is giving the error: "incompatible type for argument 1 of 'printf' " On the command line "printf (valor2);". Code:…
-
3
votes3
answers69
viewsProgram does not meet expected flow by reading and printing input
#include <stdio.h> #include <stdlib.h> int main() { int num1, num2, num3; printf("Digite o numero A e numero B para saber o resto da divisao resultante da divisao entre eles:\n");…
-
3
votes1
answer77
viewsWhy is it that when I use tabulation on a printf, there are cases where it doesn’t tabulate correctly?
I have this code: #include <stdio.h> void main(){ int fahr, celsius; int inicio, fim, incr; inicio = 0; fim = 300; incr = 20; fahr = inicio; while(fahr <= fim){ celsius = 5 * (fahr-32)/9;…
-
2
votes1
answer909
viewsHow does buffer work using printf and scanf?
Using the 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 the scanf format %c, it captures from buffer…
-
2
votes1
answer110
viewsPrinting a vector... Differences between C++ and C... Where did I go wrong?
I’m having problems printing vector structs in C, in C++ it worked... First I will show the version in C with problems (in the execution because compiles without errors) CACHE cache =…
-
2
votes2
answers3142
viewsHow 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 initial chapters. Make a program that reads a real number, and print the…
-
2
votes1
answer826
viewsHow to configure the amount 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 necessary only. #include <stdio.h> int main(){ float num=0.0;…
-
2
votes2
answers4454
viewsWhat is sscanf() and sprintf()?
What is the purpose of the sscanf() and the sprintf()?
-
2
votes2
answers59
viewsReturn the typed name
The program only returns the first letter of the typed name. I think it has something to do with the "%c", but I still don’t understand how this formatting works or maybe the data types in C.…
-
2
votes3
answers100
viewsPrintf does not print inside the while
the purpose of the code is to print the values of linked lists. Example of what the list looks like: L->[3]->[4]->[5]->X, should print 3, 4, 5. However. typedef struct lligada { int…
-
1
votes2
answers145
viewsprintf does not show the expected value
I’m having trouble showing off some printf, for example: printf("\nDigite as horas : %d"); And at the time of displaying the message, it appears with a number on the side, for example: Enter the…
-
1
votes0
answers658
viewsPrint Iframe
I am trying to print an iframe I have on a page of my site, but the print window is not opening when I use the following code: function printFunction() { window.frames["printf"].focus();…
-
1
votes1
answer159
viewsHow to Print Step by Step
I have the following program that does the following, you insert the rules(V,T,P,S), through 1 file and then vc inserts the word(GLUD) to see if it is part or n of the language that is in the rule,…
-
1
votes2
answers1323
viewsCan I replace Cout and printf?
What’s the difference between cout and printf? I learned using the printf and the scanf, but in an online course I see the teacher using cout and some pages also use cout, but others use printf... I…
-
1
votes1
answer66
viewsProblems in String and Case
I’m a beginner in programming for a little while and I have a college task in which I must create a registration system that receives the entries the customer data and then another option that…
-
1
votes2
answers61
viewsWhy do even numbers not have the same output as odd numbers?
I made a program that asks the user for a number that will serve maximum value. And then the program shows which even and odd numbers from 0 to that number. I used printf to have an output like: Os…
-
1
votes0
answers108
viewsWhat is the difference between printf and fprintf in C?
My question is as simple as this: What is the difference between printf and fprintf in C? I saw answers for Java, but since I don’t know anything about Java I don’t know if it has to do with. For…
-
1
votes2
answers101
viewsHow to handle printf in C language
Hello! How do I put something after the variable in a printf. Ex: printf("Digite um valor para a posição: [%d", l); printf(" ,%d", c); printf(" ]"); I am using the example above, but I was wondering…
-
1
votes1
answer65
viewsPrintar value of a struct by pointers
I want to print the "attribute" name of a "Person" type struct, but the printf returns (null) but I declare the struct name. Follow the code below: typedef struct pessoa{ char *nome; struct pessoa…
-
0
votes2
answers80
viewsStopped running when I added the printf
I made a source code in C, conditional, but when I add a printf function windows reports that the program stopped running. Look at the code: 1: http://i.stack.Imgur.com/a9YUf.png NOTE: I USE WINDOWS…
-
0
votes0
answers114
viewsRead TXT with Extended Ascii
I made the code below to read a TXT file that contains extended char from ascii table. int main(void){ printf("%c %c %c %c %c %c %c %c %c \n",205,187,186,187,200,201,205,188); FILE…
-
0
votes3
answers809
viewsC program "eating" characters when executed
Next, All Ides I program in C are output with characters less with each iteration. For example, when executing a for, every iteration one or more characters disappear: Note that in both netbeans and…
-
0
votes1
answer42
viewsError printing message inside condition
When I type any value other than 2 equal values, the "Invalid typed value!" message is displayed anyway. Anyone knows why? #include <stdio.h> #include <conio.h> int main(){ int x, y;…
-
0
votes1
answer2936
viewsHow do I print a hexa in c through the printf?
//example mascara=0xFF; blue= COR1 & mascara;//color a macro I used printf("%s\n", blue);//doubt bold
-
0
votes1
answer1522
viewsChange number of digits after comma depending on the situation
I know I can get a limit of digits after the comma with %.2f for float and %.2lf for double. How can I change this limit depending on the occasion? For example: Get a two-digit limit with float that…
-
0
votes1
answer251
viewsPrint a queue item by removing each item from it
I’m making a program that receives a string with words separated by comma that separates these words and lines them up (Until then I was able to do it quietly), then the program has to go removing…
-
0
votes1
answer353
viewsUse of Printf and Scanf in Eclipse and Netbeans - C Language
Good night. I have the program below that asks the user to enter 2 numbers and then present them. Code Blocks is working correctly, but when running in Eclipse or Netbeans, the system is waiting for…
-
0
votes1
answer624
viewsProblem with printf and scanf - My code does not print the correct information
I have this code here that is not reading the characters correctly when printing the data filled by the user on the screen. Can you help me?? //Question 1) Make an algorithm that reads a user’s…
-
0
votes1
answer156
viewsI have a problem trying to use an increment in the printf - C function
Can anyone help me understand why the output of this code is: 24 23 and not 23 23 ??? int a =23; printf("%d %d",a, a++); }…
-
0
votes1
answer149
views -
0
votes2
answers32
viewsAfter typing the P Value, you are not running the printf of the second for
#define MAX 15 #define TAM 2 struct { char m[MAX]; int ano; float v; } car[TAM]; int main(void) { int i; int p; for(i=0; i<TAM;…
-
0
votes0
answers103
viewsString vector condition error in C
I’m having a hard time with a specific exercise: #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <windows.h> #include <ctype.h> #include…
-
0
votes1
answer123
viewsHow to make the program stop at each printf?
I would like to make the user type a printf() at a time, being the "Name, RG and Email" but as soon as I type the name, it executes everything else and ends the program, as I make it stop in the…
-
0
votes1
answer148
views -
0
votes2
answers59
viewsProgram prints the next letter of the alphabet instead of the next char on the pointer
My program is printing the letter P instead of i, I would like to understand the problem behind this and what is wrong in my code. If I put the letter A instead of O, the program would print the…
-
0
votes2
answers981
viewsChange a text value using a C pointer
I need to change the values of the variables through their pointers but I’m not getting. #include <stdio.h> #include <stdlib.h> //Programa principal int main() {//Declaração de variáveis…
-
0
votes1
answer152
viewsProblem in returning Struct in C
I’m making a simple program in C that takes name, enrollment and two student grades but when returning the value typed struct in the function Show it does not return anything #include…
-
0
votes1
answer37
viewsHow does the diagonal sum printf of a matrix
I’m having a hard time creating a printf that depends on the input. I want you to print depending on how many numbers you have diagonally in a matrix and display those numbers. EXAMPLE: You must…
-
0
votes2
answers90
viewsPrintf() showing strange characters
The purpose of the code is to show all substrings of the variable firstString that has the same size as the second string that is the variable secondString. However, when I use the printf("%s\n",…