Category "c"

How to Identify if an input string is an int, float or char in C

I'm working on a code where I use linked list to accept a string data and put it into a main list and specific list where the data belongs. I'm having trouble o

How to traverse a matrix in a spiral fashion in C using pointers?

This is the algorithm for traversing a matrix in spiral fashion and printing the traversal as an array in Python: def spiralTraverse(array): result = []

want t print the max integer ot of four but extra 1 is added to the result [closed]

#include <stdio.h> int max_of_four(int, int, int, int); int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c

Error trying to eiliminate a specific line of a file , by passing it all to an array

I'm doing a school project, and my focus is to copy several lines of a text file to an arrays of strings and then ask to the user which string they want to remo

GCC: PLT call missing for non-library

Lets say I have a code.c with two ordinary functions outer and inner.outer calls inner. I use GCC 11.2 on Linux, x86-64. If I compile a shared lib withgcc -shar

How do I initiate multiple strings in malloc in C

I'm trying to learn C and I have an asignment to use malloc and struct and I have it print out the queue number but the string wont print. I have attached a pic

How can I implement C static variable into Go code? [duplicate]

I am trying to re-write a piece of C code into Go and I stumbled upon a static variable. I am wondering how I can achieve the Go's equivalent

Accessing an element in struct holding a pointer to a matrix array

I am trying to access an element using temp_param->mat_ptr[0][0] but it produces an error Format specifies type 'int' but the argument has type 'int *'. What

Should I set argument to pointer to const if it might be changed?

For example, given a function void func(const int* a, int* b){ *b = 2 + *a; } Should I emmit the const if func is often called like so: func(ptr, ptr) ?

When and why should I use void as the return type of a function in C?

I'm currently practising C and learning pointers and arrays. I watched a tutorial where the instructor changed the function from int aFunction() to void aFuncti

What happens to a declared, uninitialized variable in C? Does it have a value?

If in C I write: int num; Before I assign anything to num, is the value of num indeterminate?

Allegro 5 game - bitmap drawing slows down after running for a few seconds

I have a problem with my Allegro 5 code. It has three, sections, a section that checks for inputs, then a section that runs every 1/30th of a second with a time

How does the CPU cache affect the performance of a C program

I am trying to understand more about how CPU cache affects performance. As a simple test I am summing the values of the first column of a matrix with varying nu

MPI and MemoryLeaks and MPI_Wait() with async send and recv

I am new to MPI programming and I am trying to create a program that would perform 2-way communication between processes in a ring. I was getting MemoryLeaks er

I have a buffer overflow assignment like this, I set the correct varaible to the HEX value of 1 (31) and still nothing, how do I solve this

How do I set the value of correct to 1 with an buffer overflow exploit? When I pass nothing to this the value of temper is 4D2 which is hex for 1234, but when I

Linux Kernel Module never reaches ->probe() functions

Summary I want to write a simple Linux Kernel Module, which will initialize a GPIO from information it got from device tree. But currently my module never enter

Get this to buffer overflow / Finding Vulnerabilities

I have been set an assignment where I am to find vulnerabilities in the code however I don't seem to be able to find one. I am very new to C and have the basic

Keep k random strings from input file of unknown length in C

Problem I want to get input from a file of unknown length, separating the input to strings at a defined delimiter and saving some of them. After reading the ent

What does "%%%ds" mean in a c program formatting text?

This c code I wrote below to centre text in strings works. I cannot find an explanation of what "%%%ds" in the program means and how it works. There is d for in

Custom date and time including nanoseconds

For this program I need to "grab the start time of the entire process within the max. time precision avail including nanoseconds." in the format: April 9, 2022