All Questions
118 questions
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 ...
0
votes
2
answers
89
views
Problem with printing values from a struct using a void function
I am trying to make a program that uses a struct to store the title the author and the pages of a book.Then I want it to find which one has the lowest amount of pages and then use a void function to ...
4
votes
3
answers
94
views
Why doesnt the following programm prints the list?
I am currently learnig single lined lists and i am trying to write the basic functions and I tried to print my list after i initialized few elements but my programm has a logical bag because i am ...
1
vote
1
answer
101
views
printf() function with some "relationship" with my pointers struct in C
i was studying the C language and this power in memory management,(in this case i was studying the creation of Stack data structure in C), but when i was refactoring my code (deleting the useless ...
1
vote
0
answers
60
views
C 2D struct array printing strange
I am working in C with a 2d array of a struct defined as:
typedef struct Card
{
char word[MAX_LETTERS + 1];
bool found;
} Card;
The array values are being set properly and being based ...
1
vote
2
answers
118
views
My code keeps segfaulting whenever I try to print strings
I'm working on a game to run in the Linux Terminal. I've been working on a system to load in a map file, turn it into a string of custom structs, and then print the letter and color that the ...
0
votes
3
answers
98
views
Addresses in structures
The following is an abstract version of a problem I am currently having.
#include <stdio.h>
int main()
{
typedef struct {
char * bar
} struct_t;
struct_t foo = {};
...
5
votes
2
answers
313
views
Creating a variadic function that prints any kind of format of ("c", "f", "i", "s"), but doesn't work
I've created a struct, that groups the format character and a pointer to the function which prints according to the formatter.
typedef struct formatter
{
char spec;
void (*print)(va_list);
} fmt;
...
-1
votes
1
answer
33
views
Having issues to printf numbers in this typedef struct algorithm
Im doing this struct to print the register of some people i want to register, saving in a array and printing but when i used float it was printing a memory dump and now the int numbers are becoming ...
0
votes
1
answer
127
views
snprintf function keeps pausing and cause the program to terminate in C
I have been working on this function that takes a customer struct and returns an allocated string with detailed info using snprintf to form the string.
char* to_string(customer cus)
{
char* buffer ...
-1
votes
1
answer
99
views
C code crashes when running strcpy() for the second time
I have a struct that looks like the following:
typedef struct
{
char matrikelnr[10];
double note;
} Hashtable_Entry_t;
And then I try to fill the struct in the main:
#include <stdio.h>
#...
0
votes
1
answer
272
views
I have exception thrown error when I try to printf
Exception thrown at 0x00007FFD4B79FAAD (ntdll.dll) in IPC Final.exe: 0xC0000005: Access violation writing location 0x00007FF71469C5D8.
When I tried to print, I got this message.
I am trying to open a ...
0
votes
2
answers
71
views
Printf give an undefined behavior while using Struct in C
I'm new to C Programming. Im really confused why printf gives undefined behavior output. I tried to double-check every command and I don't think there is a mistake with my current knowledge. What was ...
0
votes
1
answer
63
views
Reading string value appears as NULL
This program when it receives the input 1, it receives info from the user and if the input 2 is given it shows what it has stored so far.
The issue is that when you select 2 after having inserted the ...
0
votes
1
answer
51
views
How can i print an interior supply of structure on c?
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
struct game{
bool is_computer_game;
bool is_tabletop_game;
bool ...