Category "c"

xv6 C skipping blank lines

I am trying to write a program in C (for xv6) that returns the last "n" number of lines of input text or a file (essentially tail) with the exception that it sh

How to change c syntax check standard in vscode

vscode default c syntax checker seems that c standard used not high (maybe c99 or lower) like the example following: array ellipsis is available in c11 , actua

CS50: Filter Edge Returns Mostly White Image

I have been stuck on CS50 Filter - Edges for a few days now, having a hard time determining what's wrong with my code. This code returns an almost all white ima

How to detect if a block of memory already freed

I already know that there is no way to know if a pointer target still a valid allocation of it's already freed, so I'm trying to use pointer to pointer to solve

Save page of WebKitWebView into file

I have this almost solved. I've found this function: void webkit_web_view_save_to_file (WebKitWebView *web_view, GFile *file,

Which all multicast groups are available under custom netlink protocol

I am trying to send a notification message from a kernel module to user space application using netlink sockets interface and custom netlink protocol. My unders

How to use dynamic 2d array inside a struct array in C?

What do I want to do? I'm working on a project on dynamic matrix multiplication. I want to input from the user that on how many matrices, he/she wants to perfor

cannot cast 'float64' to different essential type 'unsigned16' [MISRA 2012 Rule 10.8, required]

cannot cast 'float64' to different essential type 'unsigned16' [MISRA 2012 Rule 10.8, required] double x, y; #define MIN 2.0 uint16_t z = (uint16_t) ((x * MIN)

The pid works only once after the two calls to scanf

This program creates a pid and shares two integers (base and height) through the shared memory. The parent process time asks four times to insert two integers a

Faced an error: excess elements in char array initializer during print out of array of strings

I've tryed to print out some array of strings but faced error: excess elements in char array initializer Please make a hint what's worng with this code? Step 1

how can i pass string(taken as input from user) to a pointer function in c?

#include<stdio.h> void add(int a,int b) { int c=a+b; printf("\nSum=%d",c); } void hello(char *name) { printf("Hello %s",*name); } int main() {

Binary search program cause runtime error and failed hidden test cases

I am practicing binary search with problem 704 on leetcode. At first, I just follow the concept of binary search and came up with this solution: int search(int*

Different output on recursive call using static variable [closed]

int fun1(int x){ static int n; n = 0; if(x > 0){ n++; return fun1(x-1)+n; } return 0; } int fun(int x){

What is the difference between using INTXX_C macros and performing type cast to literals?

For example this code is broken (I've just fixed it in actual code..). uint64_t a = 1 << 60 It can be fixed as, uint64_t a = (uint64_t)1 << 60 but

OpenVAS libgvm_util.so: undefined reference to `MQTTClient_`

Have some troubles in compiling from source https://github.com/greenbone/openvas.git cmake was done successfully, but make failed with: /usr/bin/ld: /opt/gvm/li

Having problem Understanding fork() hierarchy tree

I have this Code that I can't understand. I understood the basics of fork() but I don't understand the Hierarchical tree for this process. The code is like this

OpenSSL BIO_read is wrong

This is the code how I am reading the response from my HTTPS request: int len = 0; f = fopen("response.txt", "wb"); do { char buff[1534]; len = BIO_read

why does malloc not taking in the full text? [duplicate]

Why is it when I try to take in a text in the variable is does not store in the full sentence. The malloc seems to not allocate enough memory

c program doesn't takes "space" as input to show the acsii code

The program shows output for all other characters instead of space. When I enter "space" it doesn't do anything and just waits. #include<stdio.h> #include

Linux getenv() could not get $PS1 or $PS2

My home world is to write a shell. and I must use $PS2. but when I write a code like this: char *ENV_ps2; ENV_ps2 = getenv("PS2"); I just found ENV_ps2 was