Questions tagged [conversion-specifier]

120 questions
0
votes
1 answer

How to make a request with a conversion specifier in Python?

I'm trying to send a query that is URL-encoded as follows. However, an error occurs because % and & in the query are recognized as conversion specifiers. How do I solve it? import…
Sliced_ice
  • 37
  • 4
0
votes
1 answer

Sscanf will read ints but not doubles (c)?

I have the following stored in a char array "1, 1.0, 1.000, 1.0000" I am trying to parse it into an int and three doubles with the following sscanf(myString, "%d %lf %lf %lf", &(myStruct->I1), &(myStruct->D1), &(myStruct->D2),…
0
votes
3 answers

how to compare 2 input with if else in c? and how to make yes or no selection in c?

may i have some help? Here's my script. #include void main(void) { int u; char ktp; printf("Masukkan umur anda : ", &u); scanf ("%i ", &u); printf("Apakah anda memiliki ktp (y atau n): ", &ktp); scanf…
Rey
  • 1
  • 1
0
votes
2 answers

Which placeholder should I use in and why?

Why the code only works when I use the %lf or %f place holder (second placeholder), but its printing 0 when I use %d? #include void main() { long id; id = 123456789; double Hourly; Hourly = 30; int HoursAday,…
0
votes
2 answers

My while loop in C replays one more time than it should before it ends

When given input, my while loops print one time extra before closing its loop. For example, 8 7 38 3 -5 -1 q is my input that prints out Provide 6 integer coefficients for the brute force equation solver: Solution found: x = 3, y = 2 Run program…
0
votes
2 answers

I wonder why &a(Data type: char) is printed as value not address, using %s

#include int main(void) { char var = 'z'; printf("[buf]: %s \n", &var); // the output is z~~~~~, but the first char of output is only z. why?? }
y J.
  • 131
  • 4
0
votes
1 answer

Erro expects argument of type ‘int’, but argument 3 has type ‘int *’

I'm trying to compile and display the address of each value into the arrays. int i[10] = {1,2,3,4,5,6,7,8,9,10}, x; float f[10] = {1,2,3,4,5,6,7,8,9,10}; double d[10] = {1,2,3,4,5,6,7,8,9,10}; /*int *p_i = &i; …
0
votes
2 answers

what does mean this exception ? format %d expects argument of type 'int', but argument 2 has type 'long long unsigned int' [-Wformat]

I'm a student trying to learn C and C++, I've got a problem with the specifier %d I dont't understand the exception that is written in the console, It's writing The format %d expects argument of type 'int', but argument 2 has type 'long long…
0
votes
2 answers

static variable changing value with no error displayed?

Code: #include int main() { int a=10; static int b=2; a = a+1; b = b-1; printf("%d \n",a); printf("%d \n",b); printf("%d \n","%d",a,b); return 0; } Output: 11 1 4210693 My Question: b is a static…
user134613
  • 109
  • 4
0
votes
3 answers

Having error:invalid type argument of unary '*" (have 'int')

This is my first question on here and im still learning c, and i was writing this code to enter details of a user bank account to file and reading all records back from file, when the error, error:invalid type argument of unary '*" (have 'int')…
silvercen
  • 11
  • 3
0
votes
0 answers

Need help on format string vulnerability

#include #include #include int main(int argc, char **argv){ int i = 1; char buffer[64]; snprintf(buffer, sizeof buffer, argv[1]); buffer[sizeof (buffer) - 1] = 0; printf("Change i's value from 1…
0
votes
4 answers

Why is the sum of two Integers in this case not working?

I'm new to C Programming and I am stuck on a simple problem. Here is the following code... #include /* Write a C Program that accepts two integers from the user and calculate the sum of the two intergers. Go to the editor! */ int…
Gregory
  • 177
  • 6
0
votes
2 answers

16bit unsigned int array outputting more elements than initialized size in c

I'm trying to feed data into an array and change only a few values and leaving the rest 0, but I keep receiving much more data than the array should theoretically hold. Here is my code compiled and run with gcc -o arr arrayconst.c #include…
rob ell
  • 45
  • 7
0
votes
1 answer

Unable to change certain array data by passing address of pointer to an array as argument to the function

The b array stores the address of the a array which contains single character value. But by calling the fun function I want the the each b array element may contain string (multicharacter) value. Suppose I want to change the *b[1] value in the array…
user3559780
  • 351
  • 1
  • 2
  • 12
0
votes
0 answers

Why is there no output when I use a float conversion specifier in C

I wrote the code below for a lab assignment, but the output isn't what I expect. There are no errors, but the formatted float doesn't show up. May someone explain what I'm doing wrong? Any help would be greatly appreciated. My code: /*Include…