Category "c"

Register external C library to avoid incorrect diagnostics / treesitter highlighting in neovim

I want to write a C file + get correct diagnostics and tree-sitter syntax highlighting in neovim. Everything works fine, unless I include an external library (i

File reading in C with fgets entering into a never ending loop

I'm attempting to do basic file reading in C with fgets. It should read one line, pass it to the tokeniser function which should split it at every ' ' and add

How to capture names of clicked folders in the right pane of a GtkFileChooserWidget (GTK4)?

My box runs Ubuntu 21.10. I use GTK4, C-language and XML description of the GUI. I am new to GUIs in general, and to GTK4 in particular. The program uses a GtkF

Write a C function GetEvenNumber

For my studies, I have to write a C function GetEvenNumber: parameters: array with n integers + array size; returns tr array which contains even integers from t

File reading with fgetc in C

I have a simple file reading algorithm but it's not returning the values that are in the file. The below is the code. The input txt values are 200 53 65 98 183

Connecting your own header file in C

Project structure: enter image description here When starting the makefile, I get an error: src/main.c:1:10: fatal error: lib/hello.h: No such file or directory

Why the characters in buffer cannot enter a while loop?

why there is no "*" in output? the input is : abcde[enter key] #include<stdio.h> int main(void){ char ch; while ((ch=getchar( ))== 'e') pr

How to check if a string passed as argument is a modifiable string

The question is pretty much in the title. The code void modify_str(char* str){ if(strlen(str) > 5) { str[5] = 'x'; } } Will invoke undef

Reading comma-separated words from a file

FILE* inp; inp = fopen("wordlist.txt","r"); //filename of your data file char arr[100][5]; //max word length 5 int i = 0; while(1){ char r

Is there a way to do a syntactic/symantic diff of C code?

NEC2 was originally written in Fortran and there have been two different ports to C from the original Fortran (xnec2c and necpp). The variable and function name

Why am I getting segmentation error in a Caesar cipher program?

I'm trying to write a program that uses Caesar's algorithm to cipher a string input. I'm a beginner to C but I can understand basic codes. So to cipher the text

display all blocked and pending signals at one time

The following program checks if a signal is pending. I use the sigpending function to return blocked (or waiting) signals. The problem is that I don't want this

Sequential storage structure of linear tables and their basic operations with C

I'm new to C, and in order to practice I found a task on the Internet: Write C code that has functions that can: (1) Create a linear table; (2) Input data elem

Branch Instruction Inline ARM Assembly Causes Seg Fault [duplicate]

I wrote the following code based of off Confusion about different clobber description for arm inline assembly and it works fine: #include <

How to deal with the small stack size in MinGW?

I have the following code #include <stdio.h> //#define arraySize 5 #define arraySize 500 void func(double B[arraySize][arraySize]) { B[0][0] = 5; } i

What is the wrong point of my insertion sort sample program

While I practice C,I developed sample insertion sort in C. after some search and refer some materials ,I wrote following one. After that,I build and run. gcc in

Linked lists printing function does not work

#include <stdio.h> #include <stdlib.h> #include <string.h> struct charact { char ch; int occurs; struct charact *next; }; typedef

Power of 3 in mod 1000000007

Let k be a positive integer. Is it possible to find out the value of 3^k in mod 1000000007? I have written a C program code to do this but it gives a message on

Using "fsgets" in C How can Split string and make a structure

i want to read from the file using fgets and send the information to struct in array so i write this code but the output in incorrect this is the file i tried t

How can I get arguments from standard input in C? [duplicate]

I have a string that I want to execute in C file and I'd like to get the string from standard input. echo "Here is some random text.\n" | ./ma