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
14 views

How do increment and decrement in C teally works [duplicate]

int x=10; x=x--; printf("%d",x); Why is the output 10 and not 9.. yes it is a post increment. In line 2, x=x-- , x was assigned to a value of 10. And then x was decremented. But why it is ...
1
vote
0answers
38 views

Assigning value to pointer within function, and then using it in another function

I'm a beginner C programmer and my assignment is to find the maximum value in an array, count the number of times that value occurs in the array, and assign these two values to pointers (parameters in ...
0
votes
0answers
7 views

Cython - Replacement for def __init__() method since Cython's Python functions and methods cannot handle unsigned char arrays with values of 0

all. I have this Cython code example down below where I have an unsigned char array, a filled with unsigned integers. When I pass in this array into a Python def method, the value of any index after ...
0
votes
1answer
54 views

Strcmp not working, even when comparing the same character

I'm baffled. I'm working on a project that requires the use of strcmp and it doesn't seem to be working at all. Above you see an example in gdb where two characters are said to be unequal. Obviously ...
0
votes
1answer
32 views

Why does the the count variable in my function not increment?

My function notFull(classc,reservations) doesn't seem to return a 0 at all if(notFull(classc,reservations)==0 ) { printf("%s class is FULL.Would you like %s class\n?", classc==1? "...
0
votes
2answers
17 views

How to parse the message to get sender phone number and text messege in a C program?

Here is response of the AT command I want to read only phone number and text message? How can I code for this? +CMGR: "REC READ","+18142150657","Joseph cell","11/02/24,19:53:35-20",145,4,0,0,"+...
0
votes
0answers
6 views

Getting a Time Out error when using a ADC hat (Waveshare 24bit ADS1256) on a Raspberry Pi 4. Need help troubleshooting

I have a brand new Waveshare 24bit ADC hats for Raspberry Pi (https://www.waveshare.com/high-precision-ad-da-board.htm). It's plugged into a brand new Raspberry Pi 4 Model B I've installed bcm2835 ...
1
vote
0answers
10 views

Format Sensor data marshalling in Sig Mesh Bluetooth

I'm using sensor model and sensor mode setup for my project to read sensor data, I referenced example code of Cypress and STM electronics, but Sensor data marshalling of them not format the same, ...
0
votes
0answers
17 views

Valgrind: Conditional jump or move depends on uninitialised value. Check is null. C

I have this code: // list.h typedef struct Node { struct Node *next; int *data; } Node; typedef struct List { Node *head; } List; // main.c #include <stdio.h> #include <stdlib.h>...
0
votes
0answers
14 views

How do i pass a pointer to a char matrix (2d) by reference to a function?

It can only be done by reference, it was requested to be done as such (can't use aux structs nor global variables)* Also the xy sizes of the matrix are dynamically allocated in the main scope, using ...
-2
votes
1answer
14 views

How to get the output of this C program?

#include <stdio.h> int main () { int a[3][5] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int *p[] = {*a, *(a + 1) , *(a + 2) }; int (*ptr)[5]; ptr = a; printf ("%d\n", *(*(p + 1) + 1))...
-1
votes
0answers
21 views

Flipped Floyd's triangle in C

https://i.stack.imgur.com/kaQCQ.png - exercise I need help with. I did like rotated triangle but not in good way, I need help with this. ROWS: 5 Output I am getting: 15 14 13 12 11 0 ...
-2
votes
0answers
26 views

How to slice an array in C in the same way as we do in Python [duplicate]

I am trying to create a function in C which does the work of slicing an array (similar to python). I am encountering the errors: 'Expression must have pointer to object type (for i)' 'Expression ...
1
vote
0answers
7 views

How to pause receiving data from a specific stream without blocking other streams using nghttp2?

For the embeded device, memory resource is limited. client side needs to pause receiving data from the server without blocking other stream and will recover receiving at a proper time point by using ...
-2
votes
2answers
15 views

Summation of inputted numbers in c

I am working with this line of code my problem is every time i input a number the value of my sum is not updating. Any help would be greatly appreciated. #include <stdio.h> int condition(...
1
vote
1answer
27 views

How to find 64-bit divisions in existing C code?

Does anyone know a way of finding 64-bit divisions in an existing codebase? Possibly by introducing a compile error or warning for 64-bit division. (gcc or clang)? Background is I would like to ...
0
votes
1answer
24 views

Counting the letter 's' and 'S' from a file

I am working on an assignment where I have to read a file in c and count the how many 's' or 'S' are in the txt file. I am almost done with the assignment, but I am having trouble with counting the ...
2
votes
0answers
21 views

Z_STREAM_ERROR from deflate() on Solaris only

We have been successfully using zlib in R's data.table for several months now out in the wild with no problems on Windows (64bit and 32bit), Linux and OSX. But just on Solaris we see an apparent ...
1
vote
1answer
17 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/...
1
vote
1answer
38 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
31 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
74 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 ...
-10
votes
0answers
40 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
1answer
47 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 (...
-2
votes
1answer
65 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
31 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. Have client open text file. have client store text file content in a ...
0
votes
1answer
40 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
13 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
21 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
58 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
70 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
15 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
36 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
60 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
18 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
51 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
49 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
33 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
27 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
24 views

Why I can't see all printf output in console [closed]

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
40 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 ...