Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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

Homework program that reads input from another file in C

For this lab, you are to write a a program that will first read in the heights and weights of a series of people from a file named values.dat. Create this file using your editor so that each line ...
-5
votes
0answers
16 views

Is there a website or software that can take input and output a specific string of formatted text? [on hold]

def unlock_doc (): u = input("caller/ requester?: ") a = input("Analyst Full Name?: ") s = input("Server?: ") db= input("database?: ") dn = input("document number?: ") v = input("version number?:...
0
votes
1answer
17 views

Passing the size of a 2D array to a function?

The assignment is to write a program that takes in strings from command line input and sets them all separately to an array of strings.Then for each string check if it uppercase or lowercase and ...
1
vote
1answer
19 views

Problem while checking if a string is a number in c

For a problem in CS50 class, I have to check if a key is valid, i.e if the input given by the user is a number. I tried different codes but every time, if there is at least one digit in the input, it ...
0
votes
1answer
35 views

Find largest prime number below input value

Let me start by saying that I am a beginner. I've been tasked with defining a function that calculates/identifies the largest prime number below an input value. However, my current approach is flawed. ...
1
vote
1answer
29 views

Segmentation fault on 2D arrays of certain size

I'm creating a program with multiple threads where one of threads creates 2 matrices based on input. These inputs are n and seed. Input specifies the square size of the matrix (n x n size) while seed ...
0
votes
1answer
18 views

Arduino and Pointers to char array

Need to get a pointer to a char array variable. char hostName[] = "Server1"; uint32_t *p; p = &hostName; My understanding is probably lacking seriously, but I cant figure it out. I get ...
2
votes
0answers
15 views

Can we reduce ESP IDF boiler plate size?

I tested running bare bones code using ESP IDF on an ESP32 chip using duinotech XC-3800, and obtained the following results in terms of image size. Analysis Binary Size for ESP32 Folder Structure ...
0
votes
0answers
6 views

How to extract pointer type information using python clang bindings

Using the python clang bindings, how do I figure out to what type of struct my pointer is pointing to? More specifically, using a parser search function I wrote, I'm able to extract the node of the ...
0
votes
0answers
24 views

How to traverse through linked list multiple times and eliminate nodes?

I am trying to solve the Josephus problem using a linked list - https://en.wikipedia.org/wiki/Josephus_problem. Basically we have a specified number of people - let's say 6 with k being 3. I start ...
1
vote
3answers
54 views

Why am I able to re-assign a new string to a char pointer in C like so ( ch *string = “hello”; string = “assign”;)

I would like to know why the following code is legal char *string = "hello"; string = "changed"; string = "changed again"; This does not cause any problem with the compiler. But I was under the ...
0
votes
0answers
19 views

How to create and store (secondary memory) an index structured as a B-Tree?

I searched a lot, but I did not find anything objective or conclusive about it. I would like to learn how to build an index structured as a B-Tree. There are two files: main.bin (file where all my ...
0
votes
0answers
25 views

Function is behaving like it destroys the table inside the if statement

It does returns the i value since for some reason it does not adds +1 to the counter and it cannot enter the if statement The function is supposed to be returning the starting position of the word hi ...
-1
votes
0answers
42 views

What is a good method for implementing a memory-efficient, disk based hash table? [on hold]

I'm in the proccess of making a C console program for my college course, which manages some vet medical records, by storing them in structs written into a binary file. The assignment requires me to ...
1
vote
1answer
13 views

I'm making a linked list that has to swap it's order

I'm writing a program that uses a doubly linked list. first, it takes 2 numbers from the input. the second number is to be used later but the first number, n, is used in a function to arrange the ...
1
vote
2answers
46 views

How function calls with parameters work in C?

I am learning C and came across something I was curious about. For me, calling foo in main like follows does not return anything: int foo(bar){ return bar * 2; } int main(){ foo(10); } Only ...
-5
votes
0answers
48 views

What are the functions of graphics.h? [on hold]

What are the parameters of circle(), rectangle(), line() and the other functions in graphics.h?
1
vote
2answers
40 views

How to read and print the contents of a txt file in C

I am trying to find an easier way of reading a text file. I have never programed in C before so this is all new to me. My goal is to be able to run my program and have it automatically print to the ...
0
votes
0answers
27 views

How do I remove spaces before parameters initialization in clang-format?

In clang-format file code is appared in the same verticle position as initial parameters. I'd like to have the initial parameters have no space but rest of the code should have space of 4 spaces(...
0
votes
0answers
49 views

putting strings into linked list

My wordcount function has some issues. If anyone can please help. I am reading characters from input file, converting them into words. I add them to linked list and using print statements checking ...
-3
votes
1answer
41 views

Am I defining a function wrong in C?

Code runner in VSS Code is able to run my code and it works properly but there's and issue with the code, the vratiRez fucntion. I don't understand the issue, it says: expected a ";". #include <...
-1
votes
1answer
30 views

Memory Leakage when accessing, using pointer, elements from a struct received by argument

A little of context: I have recently developed a generic function to update a display image based just on which parts of it have changed. For that I receive as parameter a known struct which members ...
-3
votes
0answers
22 views

Is it possible to get data from DataGrid, ListView or Menu via user32.dll / WinAPI?

Tell me please. I use in C# export user32. Is it possible to get data from DataGrid, ListView or Menu via user32.dll / WinAPI. If the question is stupid - do not swear please. I have only recently ...
4
votes
1answer
55 views

Split a list into equal parts?

I have an array of size elements, and I have a function that will split it into roughly equal sections. It does this by setting the size of the first size-1 sections with size/num_of_sections, and ...
0
votes
0answers
17 views

How can i include SDL_gfx libraries in a Clion project?

So there is a weird thing that I've encountered, where i can make the SDL2 libraries work in clion but if i include the SDL_gfx libraries it won't compile. So here is what I've done so far: I've ...
1
vote
0answers
21 views

How to trace the reason for compilation errors in a pecl zip install operation (with a legacy version of PHP)?

I have an unavoidable need to develop systems based on PHP 5.4. I am aware that this is well out of security updates, but it is what I have for now. I wish to create a PHP 5.4 Docker image for ...
-1
votes
2answers
80 views

Sizeof with different specificators [duplicate]

I want to know why sizeof doesn't work with different types of format specifiers. I know that sizeof is usually used with the %zu format specifier, but I want to know for my own knowledge what ...
-1
votes
1answer
45 views

Using od command on linux has it backwards? [on hold]

Story of the situation, building an assembler with a pre-made assembly language. I am building the commands in my C program. It works, but it comes up backward. My program reads through the test ...
-2
votes
0answers
36 views

Comparing pointers and its only comparing the first part [on hold]

I'm having an issue with pointer comparison it is only comparing the first set of bytes in my pointers. length = Length of the pattern of bytes. pattern = a pointer to the byte pattern being ...
-5
votes
0answers
30 views

Does arithmetic coding require reading input twice [on hold]

First task at my university's encoding class is to write an archiver/unarchiver using arithmetic encoding. To get the best score you've got to make it as optimal as possible. I don't know whether ...
-1
votes
1answer
41 views

C program not running properly on raspberry pi

I'm currently designing a hemming code. This code works perfectly on my computer but when I port it over to my pi, it just does not work properly. I have no idea why and I am pretty new at C and the ...
0
votes
2answers
36 views

To generate 10 random numbers between -1.5 and 1.5 and write them in a ran.dat file

I have tried this Fix the range and also compute average and number of data greater than average #include <stdlib.h> #include <time.h> int main(){ int i; float num; srand(...
1
vote
2answers
59 views

Taylor Series in C (problem with sin(240) and sin(300))

#include <stdio.h> #include <math.h> const int TERMS = 7; const float PI = 3.14159265358979; int fact(int n) { return n<= 0 ? 1 : n * fact(n-1); } double sine(int x) { ...
-1
votes
1answer
57 views

I'm having problem with my C function code [on hold]

I want it show me sum of numbers that I enter for example:123=1+2+3 but it wants number from me forever #include <stdio.h> int totalOfNumbers(int number) { int i, total = 0; while (...
1
vote
0answers
15 views

PangoCairo shows cluttered text when cairo context is scaled

I'm playing around with PangoCairo and found out that if the cairo context is scaled, pango draws letters closer together when scale is less than 1 and spaced from each other when scale is more than ...
0
votes
0answers
29 views

Finding out readability level using Coleman-Liau index using C

I am writing a program to find out number of letters, words, and sentences. Using these values, I am using Coleman-Liau index to find out the article's readability level. I think I have a pretty ...
0
votes
0answers
35 views

The simplest graphical library for C? Windows 10, Visual Studio [on hold]

In my program I have very simple dot-objects which are moving around XY axis in 2d plane. I really need the simplest possible solution just to draw them graphically in colour like single (or many if ...
-1
votes
0answers
26 views

Cannot open source file unistd.h

I read the OSTEP and in the section were need to write a code I have an error. As I understand, I'll need to use Unix OS but I don't understend where and how to do it in VS. Where I need to write it....
1
vote
0answers
29 views

Format String Vulnerability Lab

First year Cybersecurity student here (I am new to a lot of things, like Linux and such) I am having some trouble modifying a secret value in my lab. Here is what I need to do for it gcc -z ...
0
votes
0answers
24 views

C++ MPI_Reduce rows of the matrix

I am a new to MPI and struggling to do the global reduce operation for my matrix. I have done the reduction, using the materials I have found. But I want to do this not with a generated 1D arrays, but ...
0
votes
0answers
34 views

add correct sign, decimal point and convert to float from two char in a buffer

Im reading a buffer and one char in the buffer represents the number before the decimal and char represent the number after the decimal. I need to concat these, add the decimal, then do 2s compliment ...
0
votes
1answer
45 views

C: Pointers to array of struct in function

I want to create a function that will enable or disable the some parts of the functions with conditions. I have created a struct that contains 4 members (enum types, uint8 catNumber, char Name, bool ...
-6
votes
0answers
42 views

How to get time in hh:mm format? [on hold]

I need to get a time in HH:MM format. And I have to print out the time in minutes from midnight. Never worked with time.h . So i can type in that " 10:45 " , but its a string. It would be great if ...
-2
votes
1answer
45 views

How to loop over defined name pattern [on hold]

I have around 500 signals with the naming pattern "Dem_AllEventsStatusByte._101" "Dem_AllEventsStatusByte._102" "Dem_AllEventsStatusByte._103" ... "Dem_AllEventsStatusByte._490" I want to loop over ...
0
votes
1answer
20 views

how to convert a 2d array which is globally available to a malloc array(which can be passed as a parameter)

I want to change my globally available 2d array to a malloc array and pass it to the following function I have this 2d array as a global variable char grid[ROW][COLUMN]; I want to pass it to this ...
1
vote
0answers
27 views

boundary tag being overwritten

I'm writing an allocator as a school project to replace the reel malloc, the Boundaries Tags (where you write as metadata before and after each allocated block the size of the block and if it is used ...
0
votes
1answer
13 views

Protocol Buffer nanopb Serializing string and decoding error utf-8 character

I am currently trying to serialize a string using nanopb and decoding the message in python/java. The ints I have no trouble and I can serialize and deserialize. But when it comes to string, I keep ...
0
votes
1answer
63 views

while file writing mode how to backspace work at C [on hold]

Sorry guys, i am not good at english. So hard to explain. also i edited misstake. i did write data and write '\n' and then when data writing is End, want backspace to make EOF after data. FILE *fout;...
8
votes
5answers
228 views

How should character arrays be used as strings?

I understand that strings in C are just character arrays. So I tried the following code, but it gives strange results, such as garbage output or program crashes: #include <stdio.h> int main (...
-5
votes
0answers
20 views

node structure of Single Linked list [on hold]

Give the node structure to create a single linked list of integers and write functions to perform the following :- 1.creating list 2.assume the list contains 3 nodes with data 10 20 30 3.insert a ...