Collect all kinds of c programming exceptions and fault solutions.


How to avoid a particular line using fscanf()?

I have a file contain assembly languages for sic machine.
eg:
LDA ALPHA
ADD BETA
;This is a comment line.
;just an example code.
END
while reading using fscanf() how to avoid the co...


Most efficent way to calculate CRC64 with reflected input

I need to calculate a CRC-64 using this setup into this wonderful website: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
As you can see I require "input reflected" and that means that I


The tests on my cs50 edge filter program are failing

I'm working on the edge program for cs50. I have had a lot of problems with this program but I feel like I'm getting closer. If anyone could help me with any ideas for what could be going wrong I'd...


Using C macros in eclipse post-build step

This question has been asked before (there are questions that are 5 or 10 years old) but without any real answer, usually a different approach has been used.
I'm working on a project where a differ...


Create partitions on a disk, and put a filesystem on them with C under linux?

I would like to use a C program to create and edit the disk label, and the partitions of block devices. Is this possible in User-space, is there a syscall to do this, or do I need a kernel module in


Is there a way to define a "common" structure for multiple parameter numbers and types

I would like to create a common structure that I may use to pass parameters of multiple lengths and types into different functions.
As an example, consider the following structure:
typedef struct _...


LEA vs MOV. Assembly x86-64 gcc 10.2

I have been redirected to many stack overflow handles and even got banned to question. But honestly I did go to those places, and DID NOT Get what I wanted.
PRE TEXT:
I Understand what LEA means.
S...


256-bit arithmetic in Clang (extended integers)

I'm in the design phase of a project that needs to do a lot of simple 256-bit integer arithmetic (add, sub, mul, div only) and need something that is reasonably well optimised for these four operat...


Remote mmap syscall using ptrace (Linux, C)

I've been stuck with this problem for some days, and still haven't manage to fix it. Basically, I want to do a remote syscall from an attacker program to the target. But before showing the code, I ...


Display memory representation of C program (Linux Environment)

We have been learning about memory representation of C program for some time, but now we have been asked to use tools in a Linux environment (like nm, objdump, size and others) to prove that for a


How to printk value of specific memory adrress?

I want to print 12byte from specific memory address in kernel.
Following is my hard coding.
void *Unique_Id = 0x5C000234;
for(int i=0;i<12;i++){
printk("%02x ", *(uniqueId+i));
}
...


How To Invoke Variables To Specify Format Of printf In C Programming

I want to use variables to specify format of printf in C programming.
I am quite a C programming newbie, having practiced bash shell scritps though.
In bash scripts, I can use a variable to specify


Problem during variable atribution (0.000010 becomes a huge number) C language

EDITED TO BE REOPENED
People, how are you doing?
So, I am trying to atribute the value 0.000010 to a variable, but it becomes a very huge number, and it shouldn't be the case of overflow, due to th...


Why is the positioning of the newline character before the string leading to it not getting printed?

I am new to socket programming. I wrote a code for receiver:
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#


Writing outside heap in mergesort

I have been implementing vanilla version of a merge sort in C. In a sorting section itself, which is a separate function, I created a temporary array via malloc, like this:
int *tmp_arr = malloc(si...


How do you use gnuplot from xcode?

I want to use gnuplot by calling it from xcode. I have it on the terminal and it works fine, I just don't know how to plot from C. I have MacOS Catalina.


How can you iterate though directories without using any recursive functions in c?

I'm trying to create a program in pure C using the WIN32 api to iterate though directories trees and list any files located in them, and if it finds a folder, it should go into that directory to se...


Stack frame info / Back trace printing inside the program instead of using GDB

we have requirement to "print Back trace info inside the program" if there is issue of SIGSEGV .
Based on set of links provided in stack overflow
I am using "backtrace_symbols_fd()&q...


Refer to external symbol without leading underscore from C

I am trying to refer to object files generated by clang from ObjC sources from C code, however the compiler is generating symbols not prepended by underscore so extern specification does not work. ...


How to close sockets in C (GCC on Linux)

I'm completely new to C.
And am following this yt tutorial on sockets. However he's using the close(sock) function. There's 2 problems:
There's no variable called sock. The socket is called someth...


Why does use libc stop cargo from linking my program correctly?

I have some c code which I compiled to a .so file which i want to be called from a rust program.
//hello.c
void greet() {
printf("Hello, world");
}
so I compiled it to a shared object


i need help to implement a semaphore

I have an idea but I don't know how I could do it, from a parent process with fork () I created N child processes.
To make the child processes perform a certain action one at a time I would like to...


Delete Global Variable in C

I'm working on a bigger project in my Cortex M3 chip and I'm running low on the RAM. My proposed idea is, I need to make space in my RAM by removing the global variables on the bootloader code so t...


Check function exists in C langauge by base script program

I want to know how to check function exist in C language program by bash script programming.
Suppose I made a program in C language:
fun.c
void add();
void main() {
add();
}
void add() {
printf...


Overflow error in C code, Leetcode problem

I got a runtime error with my solution to İntersection of Two Arrays II at leetcode.
I think my insertion sort causing overflow and the solution to the problem may be using pointers with the sort...


Windows C load image

Stackoverflow said my title couldn't contain "Windows C code or library for images"
I really don't want to re-invent something that must've been done hundreds of times before, so I am try...


How to count the number of words and sentences per string in c?

Here are the instructions of an exercise that I have to solve for cs50 pset2 readability:
Your program should count the number of letters, words, and sentences in the text. You may assume that a l...


Get address of a function inside of the function in C/C++?

I was trying to return the address of a function which i called, something like :
void * myfunctionname(some parameters) {
//some codes
//more codes.
return &myfunctionname;
}
How to rep...


function that adds 16-bit variables

I am writing my first emulator (Intel 8086 microprocessor).
I'm stuck because I have to write a function that adds 16-bit variables together. Here is the prototype of the function I want to write:


Is this good error checking, how could it be improved and is there a better method in c?

So whenever I look at different examples of error checking it seems like there are allot of different ways to go about it. I wrote my own a while ago to see how it worked and if it would be any goo...


Code supposed to check for non digits doesn't work in c

I have this code that's supposed to check if the "key" ie argv(1) but it's not working. "Segmentation fault"
Here it is:
string plain; //this is in advance for my for loop
...


Running libgccjit example segfaults inside libgccjit.so.0

My test of
gcc-10 -g -Og tut01-hello-world.c -o tut01-hello-world -lgccjit
gdb ./tut01-hello-world
containing the source code mentioned at
https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html


gcc stack overflown due to weird optimization

I have some code set up similarly to the example below. This is for an embedded ARM system with limited memory so my stack is only 800 bytes for this thread.
The basic idea is I am getting fault nu...


Issues building pywinhook from source

Python interpreter: 3.7
Python library: pywinhook https://pypi.org/project/pyWinhook/.
Objective: Add some features or functions to pywinhook library.
Tutorial to build this library: This library was


I have solved the Floyd's Triangle problem. Is that the right approach?

Please review my code. I believe that you guys are expert than me. Please share your knowledge with me.I am new in problem solving era. Please give feedback to me on my coding style towards solving a


How recursion return the value?

1. #include<stdio.h>
int recursion_check(int i);

main(){
printf("%d",recursion_check(6));
}

int recursion_check(int i){

if(i==0)
ret...


To calculate power of a number using call by reference

#include <stdio.h>
void power(int *x,int *y);

int main()
{
int m,n;
printf("Enter the number and power :-");
scanf("%d%d",&m,&n);
power(&m...


Compiler contribution in assigning garbage values in c

Can we say that when garbage values are assigned to variables in C, they are related to the programs that are executed on the compiler previously ?
Like some values of previous programs retained by...


C Doubly Linked List Deletion

I'm having a problem deleting from a circular doubly linked list. I have tried various different methods mentioned here, but they all cause some sort of error. Here, I'm getting an error saying "


Are use-once datatypes in MPI a correct and/or acceptable design?

This below is prototypical MPI program that uses datatypes.
The code is a simplified version of this example: https://mpi.deino.net/mpi_functions/MPI_Type_vector.html .
As many other examples, the ...


Problem with functions in C (readability)

I am working on an exercise in cs50 pset2 readability, and I'm trying to count up how many sentences there are in a text. So far my code is this:
#include<stdio.h>
#include<cs50.h>
#inc...


The x86 disassembly for C code generates: orq $0x0, %(rsp)

I have written the following C code:
It simply allocates an array of 1000000 integers and another integer, and sets the first integer of the array to 0
I compiled this using gcc -g test.c -o test ...


Im trying to make a tic tac toe game in C, but I can't figure out how to make puts() print out a character

So, I've started to try to learn c (I came from python) and one of the things I used to learn python was to try to make tic tac toe in python. For this reason, I thought I might as well try to make...


Receiving multiple times from a single client. I can only recieve from the client once and then every response is NULL

I want the server to send a OTP (one-time password) to the client. Then the client sends the password back to the server it was received from, and if they match then furthur conversation happens.
T...


Printing ASCII letters, 10 is printed always at the end

I'm new to C and ASCII numbers, so I was using a code sample to print ASCII numbers
int main(){
int c;
while ((c = getchar()) != EOF){
printf("%d\n", c);
}
}
Output ...


Only render changed characters with ncurses?

I am wondering, what is the correct way to render updates with ncurses as efficiently as possible?
Currently, I am rendering in the following order:
Call erase() to clear everything
Write my frame/


How can I write files as a different user from IIS?

I have an ISAPI Extension written in C. One of the functions it performs is to receive a file and write it to disk.
The extension runs as IUSR so I gave write access to IUSR. Instead I want to be a...


kd-tree iterative non-stack based insertion

Im looking for iterative non-stack based (due to memory constraints, and minimal refactoring) kd-tree insertion only.
I have an entire kd-tree library working in C, functions (insert ,read, update,


How to get the client certificate or more precisely the client DN in GRPC++?

I have clearly understood how to establish a two-way authenticated SSL communication in GRPC++,but now I desire to obtain the way to get SSL client DN in the established TLS communication to make a


Why does my window only get shown after I use SDL_PollEvent()?

I'm using SDL2 in C and wanted to show something to the screen without the need for taking in inputs. But when I ran the code to present a black screen the window would not open. I proceeded to do ...


Next