All Questions
5,975 questions
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 ...
5
votes
2
answers
149
views
Why is the octal "0" prefix displayed despite the explicit 0 precision when printing 0 integer with # flag?
Why is the prefix written with octal when using both the # flag and explicit 0 precision for unsigned int conversions? Is it normal?
I've noticed this and it feels like a bug (I'm not claiming it is).
...
1
vote
1
answer
103
views
Create/append file and write a string from a dialog item, in UTF8
I'm getting text from a dialog item and from a date with:
char input[65536];
char date[11];
GetDlgItemText(hDlg, IDC_INPUTEDIT, input, sizeof(input));
strftime(date, 11, "%Y-%m-%d", tm_info);...
3
votes
5
answers
141
views
getting a stream of -1 when I pass EOF in an infinite getchar printf loop
I have just started the K&R book. It introduces a loop using getchar() and putchar() to copy characters from input to output until EOF is reached:
main()
{
int c;
while ((c = getchar()) !=...
1
vote
1
answer
86
views
converting integer to string in sprintf results in 0
I am trying to create a log function on stm32. I am trying to create a quite long string by converting multiple data values. Everything seems to work, but there is 1 position, that no matter what I do,...
1
vote
1
answer
64
views
String appearing "broken" into parts after being printed in C code
I wrote this code in C where you type a word or sentence (char s[]) and two numbers (l for left and r for right). It's supposed to seperate the string into 3 parts: 1. from start to position l-1 ,2. ...
0
votes
2
answers
101
views
Using Macro Constant in Printf Value
I'm currently creating a program that takes a CSV file, parses it, then prints out the various items on the page. Eventually, you'd have various columns of data. In order to have the columns looking ...
1
vote
2
answers
76
views
How to organize the receive msg and user current input in C network such that it's clean
The program has two threads, one to handle send, one to handle recv. User will always be prompted with fgets() to input message for send. Meanwhile, the recv thread will display the message sent to ...
1
vote
1
answer
71
views
Why do i get different results when I print out characters in the buffer when using a for loop and a printf function?
I have been practicing C and so I thought making a file encryption and decryption program would be good practice.However as I was working on the problem of displaying the encrypted form of the files ...
0
votes
3
answers
96
views
Integer Array is empty for no reason
So I have this code that is supposed to generate a random 4 digit code. It correctly prints out each generated number but when I try to print out the entire array, its empty. Or at least it doesnt ...
0
votes
2
answers
59
views
How to create a variable number of printf formats and values in a C macro?
I have a C struct, for which I've written printf formatting and value macros:
#define FREQ_MAX_SYMBOL 8
struct freq {
int num_symbols; // <= FREQ_MAX_SYMBOL
int tot_freq; // sum of all ...
3
votes
2
answers
160
views
C output changed by adding a printf
int32_t result = registers[rs] + registers[rt];
if (((registers[rs] > 0) && (registers[rt] > 0) && (result < 0)) ||
((registers[rs] < 0) && (registers[rt] &...
1
vote
0
answers
65
views
C debugger Not able to Print or take Input when in debugger mode is On
in .vscode Folder there is 4 files :.vscode/c_cpp_properties.json .vscode/extensions.json .vscode/launch.json .vscode/tasks.json:
My lanch.json:
{
"configurations": [
{
...
0
votes
4
answers
135
views
The issue of %5c causing output exceptions in C language
#include <stdio.h>
int main() {
int y = 0, w = 0;
scanf("%d %5c", &y, &w);
printf("%d,%c\n", y, w);
return 0;
}
When i input 2000 12345, the output ...
2
votes
3
answers
149
views
UTF 8 character printing
I'd like to print characters in UTF 8, for example the ಚ (U+0C9A) character. I have the following program which is supposed to work, yet it either prints out a '?' or nothing at all, depending on the ...