Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
2 answers
57 views

Using printf from c in Nasm causes the string to add random end line statment

this morning i tried to make a simple output library for my asm projects, i realized using the sys call each time is a waste of time and so i decided to automatize the program using printf function ...
Hrodebert's user avatar
3 votes
2 answers
85 views

Interpreting the format specifier in printf("%.-1f", 34.14)

Consider the following invocation of printf(): printf("%.-1f", 34.14); it specifies a negative precision value of -1. Making this call with glibc, we get: %0.-1f is this correct? If so, ...
einpoklum's user avatar
  • 127k
1 vote
1 answer
58 views

format string and vararg - can I tell compiler to check them?

I have the following function for Logging purposes: void LogE(const char* scope, const char* s, ...) { fprintf(stderr, "%s : ", scope); va_list list; va_start(list, s); ...
Raildex's user avatar
  • 4,468
1 vote
1 answer
67 views

Why does printf flush or not flush depending on where the line is in a loop?

Why, in this program, does the printf function print or not print depending on where it is inside the loop? #include <stdio.h> #include <time.h> int main() { char frames[] = {'-',...
user13456653's user avatar
0 votes
0 answers
60 views

Why does my printf function not work? Is my while loop not ending? [duplicate]

I am just trying to copy and paste the text input. After which the code must show done. #include <stdio.h> /*code to copy all input characters and paste it one by one*/ int main() { int c; ...
Suresh Karthik's user avatar
1 vote
3 answers
93 views

Does s conversion specifier specify direction / order in which characters are written?

Does s conversion specifier specify direction / order in which characters are written? N3220 working draft, 7.23.6p8 (emphasis added): s If no l length modifier is present, the argument shall be a ...
pmor's user avatar
  • 5,951
-1 votes
1 answer
67 views

getchar() taking stuff which I print using printf()

#include <stdio.h> int main() { int c; for (int i = 0; i < 10; i++) { c = (getchar() != EOF); printf("%d\n", c); } printf("As we can see, the value of c is ...
Vedant Yadav's user avatar
0 votes
3 answers
116 views

Using the malloc function once initializes all uninitialized variables with a 0

The malloc function is not supposed to initialize any value to any variable it is used on, like the calloc function does. Why then do I keep getting the initialized value of even other varibales to ...
Aditya Bhardwaj's user avatar
0 votes
0 answers
36 views

What happens when you missout an argument to the printf function [duplicate]

The following code prints out the Celsius equivalent of Fahrenheit temperatures from 0 to 300 with 20 as step. #include <stdio.h> int main(void) { int fahr, celsius; int lower, upper, ...
uj95's user avatar
  • 133
0 votes
1 answer
40 views

Printing negative value as long with %ld in printf(3) results in an unsigned output, except with explicit type cast... Why?

Here are some tests I did printf("%ld", -1); // output 4294967295 (UINT_MAX) printf("%ld", (long) -1); // output -1 So why does it print UINT_MAX instead of actual -1 without the ...
Cab the Kid's user avatar
0 votes
0 answers
78 views

C program does not write data to the file properly

My code is as follows: #define MAX_ELEMENTS 100 #define MAXIMUM_LENGTH 50 typedef struct { char teacher; int id; char day[MAXIMUM_LENGTH]; char startingTime[MAXIMUM_LENGTH]; ...
omrlv's user avatar
  • 1
0 votes
1 answer
96 views

STM32, arm-none-eabi: String is not output with printf if the string contains a leading `\n`

In my STM32 application I have the following code in main: printf("\nRunning Smoke Tests...\n"); The problem is that the whole string is not sent via UART. With some testing I found out that ...
Chris F's user avatar
  • 25
3 votes
1 answer
73 views

Strange printf not working after a getchar and getchar skipping

I'm getting crazy with C. I'm programming with JavaScript, Ruby, Python, PHP, Lua, even Java... Recently, I tried to program a simple Read-Eval-Print-Loop in C. And I have a very strange behavior with ...
Xitog's user avatar
  • 81
1 vote
1 answer
59 views

How to know how many argument vsnprintf has used, if buffer size is less than actual size needed?

I am trying to break the message into chunks of 32bytes, i am using vsnprintf to print the message. But the args are not incrementing i.e. even after calling vsnprintf the args show the first argument....
Hamza Jamil's user avatar
1 vote
1 answer
81 views

Expression evaluation in printf with %p

I am studying pointers in C. Trying a bunch of things to make sure I understand how pointers work, I found something that I don't understand. Here's the snippet of the code in question: int b = 30; ...
newbie's user avatar
  • 23

15 30 50 per page
1
2 3 4 5
397