Skip to main content

All Questions

Tagged with
5 votes
1 answer
259 views

How do I convert a `float` to a `_Float16`, or even initialize a `_Float16`? (And/or print with printf?)

I'm developing a library which uses _Float16s for many of the constants to save space when passing them around. However, just testing, it seems that telling GCC to just "set it to 1" isn't ...
Coarse Rosinflower's user avatar
1 vote
2 answers
175 views

How to force gcc to do printf checks on non-literal format strings?

const char* const non_literal_string = "Hello %d"; void my_print() { /* * I would like GCC to throw a warning when compiling this line because the * argument is not of int ...
Parminder Singh's user avatar
0 votes
1 answer
90 views

printf() prints only the first character

Recently I came across an example from the book "The C Programming Language" and decided to run it: #include <stdio.h> #define IN 1 #define OUT 0 int main() { int c, nl, nw, nc, ...
L1M80 54N's user avatar
3 votes
2 answers
91 views

How to leverage the [*]printf format type specification warnings?

As we all know and love (or hate), GCC has the capability of issuing warnings when you attempt to use the printf() family of functions with mismatched type specifications. In our code, we have a ...
Ken P's user avatar
  • 580
0 votes
1 answer
227 views

Why C is fine with overwriting memory sometimes? Fatal glibc error: malloc assertion failure in sysmalloc

Why code A works fine, but code B gives an error? The only difference is a printf. Also note that I'm accessing out of range memory. And GCC is fine with that. I even overwritten RAM memory easily in ...
Alex's user avatar
  • 27
0 votes
3 answers
162 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 ...
user avatar
1 vote
1 answer
152 views

c language, When decimal digit of %g in printf equal to 0.5, and length is more than 6, it is not upper ceil, why?

Here is my program: #include <stdio.h> int main() { printf("%g\n", 100000.5); printf("%g\n", 100001.5); printf("%g\n", 100002.5); printf("%g\n&...
HelpMePlease's user avatar
0 votes
2 answers
104 views

Printing doubles with large precision with printf, compiling with GCC

When printing with printf in a C program and specify how much characters I want after the decimal point with %.20f, it only gives me 15 characters and the rest are 0. I compile with GCC with the ...
KamenPetkov's user avatar
0 votes
1 answer
99 views

Custom printf function segmentation fault

can anyone help with this project task? I am to build a custom printf funcion after my C classes. I'm restricted to use most standard C functions. Must follow Aunty Betty coding style and below is the ...
SinaMathew's user avatar
0 votes
0 answers
463 views

Can't see the printf() output while debugging in VS Code

I tried running the following C program: #include <stdio.h> main() { for (int fehr = 0; fehr < 300; fehr = fehr + 20) { printf("%3d\t%6f\n", fehr, (5.0 / 9.0) * (fehr ...
Michael Morozov's user avatar
-3 votes
1 answer
3k views

Breaking down %5d%*.*f format specifier in C for precise output formatting

I'm working with formatted output in C and encountered the format string %5d%*.*f. While I understand the basic use of %d for integers and %f for floating-point numbers, I'm specifically seeking ...
Destello's user avatar
0 votes
1 answer
113 views

GCC : left shift operator on unsigned long long int does not work when shift is greater than 32?

Considering this simple example : unsigned long long int my_int=0b10100110; printf("%.64B\n",my_int<<40); Why is the output zero ? unsigned long long int is used (sizeof = 8), 64 bits ...
Stef1611's user avatar
  • 2,461
0 votes
1 answer
86 views

Correct use of param-no in GNU C's printf format specification

I am working on a helper function using printf format strings, so I started to examine printf format specifications in more detail, and found that GNU's manual allows the use of a param-no: https://...
z32a7ul's user avatar
  • 3,817
1 vote
0 answers
2k views

How to disable the Debugging Console of Raylib, without disabling also the other outputs?

Sometimes I want to print the value of a variable (or something else) in the console with printf. The problem is that, when compiling the C-Programm with GCC and adding the flags "-Wl,--subsystem,...
Flori's user avatar
  • 92
0 votes
1 answer
380 views

Machine-independent printf() of int64_t? [duplicate]

Consider the following snippet, compiled with gcc -Wall for two different architectures: int64_t x; printf("A: %ld\n", x); printf("B: %lld\n", x); When compiling for a 32 bit ...
fearless_fool's user avatar

15 30 50 per page
1
2 3 4 5
9