Category "c"

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

anything wrong with this trim() method in C

this method is for trimming a string in C by deleting spaces from the beginning and end. BTW iam not that good with C and actually facing some issues with deald

Why can't i use the € symbol with printf?

How can i put this symbol (€) on the terminal using c. I've tried: printf("%c",0128); 0128 is the code on the ascii table but the compiller gives the error

Different behaviors between C and Rust code snippets

I have a C code snippet which uses pipe() and fork() to communicate between parent and child process. I want to replicate it in Rust. For the POSIX APIs used in

how to set Trap flag (TF=1) in c language or assembly?

I used xinu and i want to use single step Interrupt (01H). I have two questions does TF flag equal 1 (TF==1) when xinu system initialize ? if no then how i can

C double to long conversion loses value in some cases - why?

I have the following code, which is causing me a weird double to long conversion problem. Under the hood, logCpof just writes to a special log file, using vpri

using a string to reference a struct

I'm having troubles with a function in C using a string to reference a struct, the used code is included below int Search_name (char nombre[],Nentrada user_numb

Meaning of int a[10]; int *p = a+9;

I am currently trying to understand pointers in C but I am having a hard time understanding this code: int a[10]; int *p = a+9; while ( p > a ) *p-- = (

Are defined strings set to all NULLs?

I could have sworn that I read that a string that was defined but not initialized was set to all NULLs. In other words, that char string[10]; consisted of 10 n

Split a text using different delimiters

long time no coding in c and i'm a bit in trouble. I get tex from a file formatted like that: # 3 10 P1 16 3 P2 8 1 P3 10 2 from the second line every line re

puff.c How does the huffman decoding work?

I am trying to decompress a raw DEFLATE data stream in order to understand, how the DEFLATE decompression works. I don't care for performance at the moment. I j