Questions tagged [conversion-specifier]

120 questions
0
votes
1 answer

What does it means by "%d converts the rest of the input to integer"?

See this answer I understood it except for the last statement. the conversion specifier "%d" skips optional leading whitespace and (tries to) converts the rest of the input to integer (if no errors occur). I understood the point regarding the…
user13595466
0
votes
3 answers

print equally spaced elements of a 2D array with printf

I am trying to print a 2d array that has a maximum of 3 digit numbers that are aligned when printed. For example, with a simple printf, it looks like this: [0, 232, 20, 96, 176, 0, 0] [0, 0, 24, 0, 0, 176, 0] [0, 0, 0, 0, 0, 0, 0] I would like it…
rookie
  • 1,168
  • 3
  • 14
  • 25
0
votes
2 answers

How to write multiple different data types

I am doing a "create a password" project for my class in python. I just learned common conversion specifiers and they would like me to use this in my program. So far I am stuck on the "second password", see code below: # FIXME (1): Finish reading…
Alita
  • 9
  • 1
  • 1
  • 3
0
votes
2 answers

Why isn't my function working, i need to make a distance calculator

Distance calculator, everything works until the program reaches the function, than the program just stops running. I tried removing the void and ints from the line I call the function in the main function but still nothing. #include…
Ron
  • 49
  • 7
0
votes
1 answer

Does put_time Have a Conversion Specifier Which Outputs Single Digit Days of the Month Without a Preceding Character

put_time provides 2 conversion specifiers for outputting day of the month: %d: "Day of the month, zero-padded (01-31)" %e: "Day of the month, space-padded ( 1-31)" Note that neither of these conversion specifiers will allow me to output a…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
0
votes
3 answers

int x; scanf() with %d and printf() with %c

int x; So there will be 2 bytes memory for the variable. Now, if I entered 66 and because scanf() with %d, 66 will be stored in 2 bytes memory because the variable is declared int. Now in printf() with %c, should collect data from only one byte…
0
votes
1 answer

C: Scanf string with field skipper "%*" applied on conversion specifier in while loop

I have defined a structure typedef struct EMP { char name[100]; int id; float salary; } EMP; and I use it in a while-loop for input EMP emprecs[3]; int i; i = 0; while (i < 3) { printf("\nEnter Name: "); scanf("%*[\n\t…
Hessu
  • 49
  • 6
0
votes
1 answer

c structure: Input requires number line by line by hitting "enter" after each number

How can I add the 10 digit number without write one digit in each line. struct test { unsigned short telephone[10]; //Some Code Here ... } for (j = 0; j < 10; j++) { scanf("%d", & seats[position - 1].telephone[j]); }
arvins
  • 19
  • 5
-1
votes
2 answers

why does the first code is unable of storing the sum in a char, but the second stores it; whats going on when i scan the values that is different?

I have this working code that assigns fixed values to some unsigned char variables: #include #include int main2() { unsigned char a,b; a=1,b=2; a=(a+b)/2; printf("\nAverage: %d\n%18d",a,sizeof(a)); return…
-1
votes
1 answer

I'm having a problem with a char variable (New to programming with C)

I keep getting one bug in the terminal which says: warning: format specifies type 'char *' but the argument has type 'int' [-Wformat] scanf("%c", namehumaninput); ~~ ^~~~~~~~~~~~~~ The course I am taking is saying that all I need…
Skibi OS
  • 17
  • 1
-1
votes
1 answer

C Language: The datatype "double" is acting like the datatype "float"

I am learning the language C. I am trying to print a set of numbers in the datatype "double" but it is only printing 7 digits like "float". For example: double temp = 23.3456789112345; printf("%1f\n", temp); Outputs this: 23.345679 However, once…
-1
votes
2 answers

Problem in code of C language In applying Arithmetic Operation between Inputs?

/I took input from user as 'a' and 'b' but in 'b' it takes 0 by default ..... whatever i give in 'b' as input it showing 0 as 'b' on applying Operation.... C code ....../ #include int main() { int a,b; printf("Enter the I no. :…
-1
votes
2 answers

what is wrong in this code...it is not taking input after I enter t

#include void main() { int t,i=0; scanf("%d",&t); while(t--) { char c; scanf("%c",&c); char s[10]="codeforces"; while(s[i]!='\0') { if(s[i]==c) …
-1
votes
2 answers

Why is sscanf behaving like this when converting hex strings to number?

I have written a piece of code that I am using to research the behavior of different libraries and functions. And doing so, I stumbled upon some strange behavior with sscanf. I have a piece of code that reads an input into a buffer, then tries to…
Espen
  • 2,456
  • 1
  • 16
  • 25
-1
votes
1 answer

Problem with taking input from user in a function

I am creating a program that takes in the input for students' names and 4 test scores and prints them out in the grid. This is done in the void function insert_data. At some point in the function when it takes in the input for the second student the…
bursikif
  • 21
  • 4