Questions tagged [c]

C is a general-purpose programming language used for system programming (OS and embedded), libraries, games and cross-platform. This tag should be used with general questions concerning the C language, as defined in the ISO 9899 standard (the latest version, 9899:2018, unless otherwise specified also tag version-specific requests with c89, c99, c11, etc). C is distinct from C++ and it should not be combined with the C++ tag absent a rational reason.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

What does the gcc warning “coverage_mismatch” mean?

Today I meet a Werror=Wcoverage_mismatch error when compiling some erlang/opt: beam/beam_emu.c: In function 'erts_current_reductions': beam/...
0
votes
1answer
29 views

Is Postgres using memory context because of the limitation of C?

Postgres uses memory context to manage its memory. https://github.com/postgres/postgres/tree/master/src/backend/utils/mmgr One advantage of doing so that I can think of is to divide all memory ...
-3
votes
0answers
26 views

How do i memorize only the parameters of a proper branch in recursion tree? [closed]

I have a recursion tree and one branch gives me the answer to my task. How do i get only the parameters of this branch?
-3
votes
0answers
65 views

Reduce binary size without using gcc optimization [closed]

I have this homework task: "Reduce the size of their compiled binaries by at least 5% as seen by the size command when exactly the same flags are used in the compilation. Make sure no functionality ...
-9
votes
0answers
34 views

Can I please have help doing this Coding Project? [closed]

Basically, I need help with creating some of the functions in this assignment. I don't know what to do about searching for names in an array. In this Assignment you will develop a file I/O based ...
0
votes
0answers
39 views

Finding a numbers with the largest/smallest number of bits set

Given a range of integers, how do I find the numbers within the range with the largest and the lowest number of bits set? For example, given the range [33, 65], 63 has the largest number of bits set (...
-1
votes
1answer
60 views

Getting null in a math function in C

I starting with C and trying to solve this problem: Write a program that asks the user to enter 3 integers, a,b,c and performs the following calculation a/b + b/c. The calculation is performed in a ...
-1
votes
0answers
20 views

TCP file transfer in C with socket (server/client)

I'm new in C programming, and I'm wondering how to transfer a file from the client to the server using sockets, using these steps. 1) Have client open text file. 2) have client store text file ...
0
votes
1answer
32 views

removing trailing and leading spaces from a file

I am trying to read lines from a text file of unknown length. In the line there can be leading and trailing white-spaces until the string occurs. So my first step is to read line by line and allocate ...
0
votes
0answers
17 views

What should I do to get coding feedback? [migrated]

I am studying C while listening to a lecture by myself. When I was studying coding and listening to a lecture, I heard that writing code should be concise and maintainable. But I didn't know if I was ...
0
votes
0answers
12 views

Using the GSL Libraries to Make Splines and Using them for Integration

Say I have a set of N data points. I can use the gsl library gsl_splines.h routines to create a spline of this data. What I would like to do is to use this spline and the gsl integration library to ...
0
votes
0answers
12 views

fork() execution, and child prcesses behavior [duplicate]

I have this code: #include <stdio.h> #include <unistd.h> int main(){ printf("hey"); fork(); return 0; } I read that the child process starts right after the ...
-1
votes
1answer
19 views

C compiler Segmentation fault. player_2_Hand[length + index]->suit

That's the error message I get from an online debugger: Program received signal SIGSEGV, Segmentation fault. 0x00000000004012c8 in Move (playerHand=0x7fffffffe710 The program is meant to be a game ...
0
votes
0answers
19 views

Why linking .cc file works in make file but linking .c file doesn't?

I'm working on a quite large Makefile from the tensorflow repo and I need to add a file link. After quite some debugging of a link error, I found out that if my file ends with .cc, then the link ...
0
votes
0answers
53 views

Just print the array in the console

I have a strange request, but I just need to output the array. I wrote the code, but my teacher asked me to also print the input array. I don't understand how to implement this correctly in my case. ...
-1
votes
1answer
69 views

I can't put a function that returns value into the int main() [closed]

I am making a university project in C and there is a problem in my code that I can't fix. It is the following: I need to put the function "float enter" in the "switch case 1", but I don't know how. ...
0
votes
0answers
13 views

Array has incomplete element type

I try to give my Void function a struct but when I do this I get a errors. first:error: subscript of pointer to incomplete type 'struct Lager'. and a warning:warning: incompatible pointer types ...
1
vote
2answers
35 views

Suffixes for integer types

Why do we use suffixes for integer types? Can suffixes determine the integer type? e.g. long int a; a = 50000LL; Is variable a now long integer or long long integer?
0
votes
1answer
41 views

polynomial sum with linked list

I need to do a polynomial sum using linked lists (C). Input example: 3 2.5 6 1.5 4 1.0 3 4 2.5 5 1.5 4 1.0 3 5.0 0 The first polynomial has 3 terms, being : 2,5x^6 + 1,5x^4 + 1x^3 Second has 4 ...
0
votes
3answers
59 views

I don't understand why a equals 1 and b equals 0 in this program [duplicate]

I don't understand why a equals 1 and b equals 0 at the end. They should be the same in my view. Thanks in advance. #include "stdio.h" int main() { int a=0; int b=0; a++; printf("a=%...
0
votes
0answers
16 views

How to specify dynamically linked symbols in header file?

I am creating a custom runtime for Wasm. I expose a set of host functions that my runtime environment makes available to any wasm module it loads. When the Wasm module is built, these extern functions ...
0
votes
1answer
50 views

Program for abundant numbers <=k

A natural number n > 0 is said to be an abundant number if the sum of its proper divisors (excluding itself) is greater than itself. For example, the number 12 is an abundant number because the sum of ...
0
votes
3answers
48 views

Functions C won't print

My program won't print out any value from the setAverage and largestNum variables. I get no errors in my compiler. What am I missing here? #include <stdio.h> #include <stdlib.h> #define ...
0
votes
0answers
42 views

Searching person by surname in array of structs

I am trying to write a program that reading data of members from the text file. Each line contain particular data. I already done that bit but now I am trying to search in array of this structs by ...
0
votes
1answer
32 views

C prints other integer number than what it shows on Watches. Why is that?

I tried adding watches and debugging it step by step,and although it works correctly on watches,it doesn't print the right value. What could be the reason for this outcome? I'm a newbie, thanks in ...
0
votes
1answer
26 views

binary tree in C - multiple data

I need to create a binary search tree that will store many members of contest. typedef struct Member{ char name[30]; char surname[30]; int id; char email[30]; }member; A key used to add nodes is ...
0
votes
0answers
11 views

webserver and endianness of files

Let assume that the webserver support only HTTP 1.1 running on a little endian machine. A random web-browser client request the file: test.txt. The file happens to be UTF-16BE encoded. The developer ...
0
votes
0answers
32 views

Brute force function for decrypting string in C ( Ceasar cypher )

I found this problem interesting, as it is given that you need to use the alphabet as an array in C. Task is to brute force every possible K value, in basic Ceasar's cipher manner. However, code I ...
0
votes
0answers
21 views

father and child not updating same file

the idea for the following code is passing 3 arguments, the child will execute the first argument, the parent the second and both are supposed to write the output to a file specified in the 3rd ...
-5
votes
0answers
23 views

Why I can't see all printf output in console

I am having some C code, where I am putting printf to debug some values. But some of the printf just don't work. I don't see the values in the console output. But If I forward output to file: ...
-2
votes
0answers
39 views

Is there a script I can make to watch wireshark for certain text? [closed]

Ok so basically I'm using an application called Wireshark and what I'm trying to do is make an application (currently using the Win32 gui in C though I'm open to other code) that will check for ...
0
votes
0answers
43 views

clarifying how recursion works in c [duplicate]

hi I am learning recursion and I need help to understand how the recursion works I understood how to use it but not all of it I got here 2 functions for example to help in clarifying what my ...
1
vote
0answers
34 views

C/C++ library for memory preallocation ( concurrent ) [closed]

Is there is any memory preallocation library for C++ with which i can pleallocate? for example - 10 gigabytes of memory on application startup and then redirect all malloc/new calls to force use ...
1
vote
1answer
33 views

How to randomize 2d array in C

for (int i = 0; i < 3; i++) { int r = rand() % 3; for (int j = 0; j < 3; j++) { int temp = mati[i][j]; mati[i][j] = mati[r][j]; mati[r][j] = temp; } } ...
-2
votes
0answers
35 views

How to count the number of windows (cmd.exe) opened?

I open several instances of cmd.exe at a time and I need a code in C, counting the number of instances of cmd.exe *32 windows open at the moment. I guess I need a call to a .dll (some sort of windows ...
0
votes
0answers
12 views

STM32 LwIP netconn_write problem transmitting structs

I am using LwIP stack with FreeRTOS in STM32F407Discovery board as TCP Client and I have a Linux computer as TCP Server. I faced a problem during transmission of a struct array, say struct EncoderData ...
0
votes
0answers
31 views

Segmentation Fault with Null Pointer [closed]

I have a method called getNode which takes a char str[] looks through a Linked List (struct Node* ptr) After adding all elements to my linked list, I'm then saying: This is what's inside my main ...
2
votes
2answers
39 views

exact control flow with int assembler instruction in C, and the resulting segfault

Consider this totally stupid code: int main() { __asm__("int $0x2"); } This causes a segfault when run. 2 is code for NMI in intel's IDT (Section 6.3.1 here). I am curious on why this segfaults ...
0
votes
0answers
39 views

why does the shellcode get segmentation fault?

I am new to buffer overflow attacks. I copy the shellcode from http://shell-storm.org/shellcode/files/shellcode-76.php I wrote a c script to test the shellcode. It looks like this: char * ...
3
votes
1answer
26 views

SQLite C API how to save query output to a string

The function showGenres runs a select query to print to the console the contents of the SQL table genres. I would like to save that result from the SELECT * FROM genres query to my char genresDisplay[...
0
votes
0answers
30 views

What is actually being sent via XBee?

I am still trying to figure out how to send my two-dimensional array via XBee and came across something that quite interrupted any thoughts I had. So I got completely wrong numbers when receiving my ...
0
votes
0answers
27 views

Null reply from hiredis command on simple C code

I installed Redis server using below commands on Kali Linux 2019.4: $ redisurl="http://download.redis.io/redis-stable.tar.gz" $ curl -s -o redis-stable.tar.gz $redisurl $ sudo su root $ mkdir -p /usr/...
0
votes
1answer
51 views

search in struct - C language

I have an assignment in which I have to create a struct with some data: typedef struct MEMBER{ char name[20]; char surname[20]; int age; }member; Then I need to read a file into stucture and perform ...
0
votes
1answer
17 views

I'd like to use the arrow keys to move around a symbol on screen in C

#include<stdio.h> #include<conio.h> #include<windows.h> void gotoxy(short x, short y); //here we declare the gotoxy function// main() int x=1,y=1; { gotoxy(x,y); ...
3
votes
1answer
40 views

Why signals are platform-dependent in Linux?

SIGNAL(7) man page states: The numeric value for each signal is given in the table below. As shown in the table, many signals have different numeric values on different architectures ... ...
3
votes
1answer
54 views

-Wformat-truncation - can I avoid it rather than disable the warning? [duplicate]

There's this code I'm compling, which has the line: snprintf(target, 11, "%02ld-%02ld-19%02ld", day, month, year); ... which is executed after it has been verified that all 3 values are valid; and ...
0
votes
2answers
20 views

Initialization from incompatible pointer type warning when assigning to a header given array

GCC gives me an 'Initialization from incompatible pointer type' warning when I use the following code. #include "mnist.h" #include <stdio.h> int main(void) { double** inputLayer = ...
0
votes
1answer
34 views

what the main function in this program returns to os?

#include<stdio.h> int fact(int); int main() { int n=2; clrscr(); return fact(n); } int fact(int x) { if(x==0 || x==1) return x; else return fact(x-1); } It ...
3
votes
2answers
42 views

What is an undefined vector element represented as in memory?

I'm currently studying C and I have a question in which I have to guess what values are in the memory. When I say, for example long var1[1243] = {10, 1, 0, -1, -10} and define this vector, the first 5 ...
0
votes
0answers
20 views

Is it possible in C to stop a pipe read with a signal?

Hello i'm making a code that starts reading on a pipe waiting for other processes to write on, but at a certain moment a third type of process starts and signals the pipe waiter, at the moment that ...