Category "c"

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

How to find neighbors average in matrix and assign it to a real number struct?

I have this assignment for college where i recieve the matrix A and i need to create the matrix B, where in each cell there whould be the neighbor's average of

In plain C, could we implement generic functions using pointers to char instead of pointers to void?

In plain C, pointers to void are useful as arguments to generic functions, such as a generic quicksort, or a generic swap, etc., as seen here: Implementation of

Why are function pointers and data pointers incompatible in C/C++?

I have read that converting a function pointer to a data pointer and vice versa works on most platforms but is not guaranteed to work. Why is this the case? Sho

Python C API Py_NewInterpreter() freezes thread when creating new sys.stdin

I am building a Python wrapper for a C++ SDK in Python The app I am building on top of is using a console that is always listening to input on stdin Everything

No output in the parent process without fflush(stdout)

I'm trying to understand what is behind this behaviour in my parent process. Basically, I create a child process and connect its stdout to my pipe. The parent p

Cannot restart typedef'd 2D array whose address is saved in struct

I have this typedef and struct: typedef double mat[MAT_SIZE][MAT_SIZE]; typedef struct matList { char *name; mat *matrix; } matList; and I create an a

Why does snprintf() take a size_t size limit, but returns an int number of chars printed?

The venerable snprintf() function... int snprintf( char *restrict buffer, size_t bufsz, const char *restrict format, ... ); returns the number of characters it