返回首页
We’re rewarding the question askers & reputations are being recalculated! Read more.

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

How to create a new node using the following structs?

I am trying to make an open doubly list. How shall I initialize/create a new node, with the given structs ? Note that I can`t change function parameters, nor the structs. The structs given to us are ...
0
votes
1answer
30 views

memcpy long long int (casting to char*) into char array

I was trying to split a long long into 8 character. Which the first 8 bits represent the first character while the next represent the second...etc. However, I was using two methods. First , I shift ...
0
votes
0answers
21 views

Programatically populate a uint8_t array

I have a uint8_t array which should look like this . uint8_t code[1000] = {0x66, 0xba, 0xf8, 0x03} Now I cant hard code values in that array instead , I need to insert them one by one from char ...
0
votes
0answers
8 views

Allocate the resource of some threads to a global resource such that there is no concurrency(using only mutexes)

The summary of the problem is the following: Given a global resource of size N and M threads with their resource size of Xi (i=1,M) , syncronize the threads such that a thread is allocated,it does its ...
0
votes
0answers
9 views

Setting PHC for Linux Device Driver

I recently upraged my linux from 3.10 to 4.4.8 After doing this I have run into an issue with my NIC drivers. I have have two NIC drivers (eth1, eth2) and their respective PHC's ptp0, ptp1 After ...
1
vote
1answer
29 views

How can I use the result from a function as a parameter to another function in C?

In a function that returns void and has no parameters I want to use two other functions (unfortunately I cannot modify that). The first of these functions calculates the result of an int and I want to ...
1
vote
0answers
10 views

The display function doesn't execute , the head value keeps getting set to null so the display function keeps printing empty

#include <stdlib.h> #include <stdio.h> struct node *create(int num); void display(void); //linked list node creation struct node { int data ; struct ...
-1
votes
2answers
31 views

need explanation on math calculation done by using c

I found following code on c #include<stdio.h> int main(){ int a; a=015 + 0x71 +5; printf("%d",a); return 0; } when i compile it, it gives 131 as the answer. but i ...
2
votes
0answers
20 views

Why using dup(1) before close(1), open(“/dev/stdout”, O_WRONLY) results in “No such file”?

Problem is same as the title, the OS is linux. I've tried a few examples. dup(1); close(1); int fd = open("/dev/stdout", O_WRONLY); This caused a "/dev/stdout No such file" error. I thought a file ...
-4
votes
0answers
20 views

invalid types 'int[int]' for array subscript in Dev c++ while doing heapify in c

Whenever I'm going to update the binary tree using right, left and max variable in the array that is visible in the highlighted portion Dev c++ ide throwing an error of invalid types 'int[int]' for ...
0
votes
0answers
16 views

C preprocessor macro to create lookup table

I have a lookup table which links all my 'two char commands' e.g. AA, AB, SS, to their corresponding function addresses in alphabetical order of the first char. The row, i.e. branch, in command_list ...
1
vote
0answers
23 views

C library linkage fail with C++

I'm using ESP32 microcontroller (C++) and trying to use "tinyexpr" library (C). I trying to link C library in my .cpp file but even with extern "C" {}, link can't completed. However, when I change my ...
0
votes
2answers
18 views

Why does struct memory initalize with random characters? (Embedded)

Using MCUXpresso with NXP MKL02Z16VFM4 for reference. When I declare a struct like so typedef struct { uint8_t DATA :8; } myStruct; myStruct xxx __attribute__ ((section ("xyz"))); the ...
0
votes
1answer
18 views

OpenSSL C Cryptopals Challenge7

I have been trying to learn OpenSSL C API. I found the interesting cryptopals challenges page and wanted to try some easy challenge. I took challenge 7, AES ECB: http://cryptopals.com/sets/1/...
2
votes
0answers
36 views

Why a redundant indirect addressing makes program to run faster on x86 CPUs?

First let me show a seemingly very silly question. Assuming that the compiler does not optimize the code, which of the following runs faster? // Let's call it "direct version" int a = 1, b = 1; for (...
0
votes
0answers
19 views

Parent process to monitore and fork new child processes depending on exit status

I've created the below code: int main(int argc, char *argv[]) { int i, n, N; pid_t pid; int status; N = atoi(argv[1]); for(i = 0; i < N; i++) { ...
0
votes
1answer
68 views

How to get only the return value of a function in c?

I declare a function with both printf in the body and a return value,how can i only get the return value without printf the things inside the body(I want to use 1 function for both things: printf and ...
0
votes
0answers
7 views

KDevelop function deprecation warnings

I'm using g_str_to_ascii() function from glib library in KDevelop project. The function was added in glib 2.40 and I'm using even newer version of that library, but it's being marked by app as ...
0
votes
1answer
20 views

Execution of mingw32-g++ failed

recently I have installed codeblocks on my new pc. But I failed to run any code. even a printf code! it is showing " it seems that this file is not built yet. do you want to build it now?". if yes it ...
4
votes
1answer
33 views

Why is STDIN not propagated to child process of different process group?

Below is the source of a program that executes cat: #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> int main() { pid_t pid = fork(); if (!...
0
votes
0answers
24 views

accessing char* or char array in struct C

ok im having a problem i cant figure out. i have a struct in header file. typedef struct client_t{ char cName[MAX_BRNAME]; char cLname[MAX_BRNAME]; int id; int clientBrNum; int accNum; ...
0
votes
1answer
28 views

Modify a character pointer string array (char * string[])

I've been giving an... interesting... task. I've been asked to modify a character array using a pointer. I'm aware that: *char = "something"; //is a literal and cannot be modified. char[] = "...
1
vote
2answers
37 views

passing array address in a function and returninf a pointer

so i am getting some kind of error , that after my array input the code doesnt run . i wanted to see if my method is wrong for inputting an array address in as a function parameter and then using ...
1
vote
0answers
31 views

Use chdir to change current working directory

I'm creating a program wich is like an "shell interpreter" but in C, in the main program called "Bash" if i write in command line "change NAME" it creates a fork and executes an execlp to call a ...
1
vote
2answers
29 views

Putting text in scanf makes the code output random numbers?

I am learning C in my computing class and we were introduced to scanf today. This is the line of code that was used to introduce scanf: #include <stdio.h> void main() { float x,y; scanf("%f %f"...
0
votes
1answer
42 views

Unable to identify the cause of segmentation fault

I am fairly new to C and socket programming and I have a project where I need to read a file via a server and then pass the coordinates from the file to the client. The coordinates are in the ...
0
votes
2answers
25 views

About Ovewriting variables in scanf()

I am creating a test program that shows an error message when an entered number is less than, or equal to, ten: #include <stdio.h> void errorMessage() { printf("\n This number is less than, ...
0
votes
1answer
44 views

How to initialize a doubly linked list with the following structs?

This is my code, I know I did not write much, but I am not knowing how to initialize a doubly linked list with the given structs. The given structs (I can`t change anything in them) /* a node in the ...
0
votes
1answer
26 views

Ringbuffer with sprintf

I'm trying to create a ringbuffer and fill it with an array of split string elements. Buffer Code is taken from here and works well enough. Here is my main and the buffer implementation: #include &...
0
votes
0answers
21 views

RedPitaya: No data in UART - can't read buffer

I am trying to read out a Sensor on a RedPitaya (running Ubuntu). The sensor (RM08 rotary encoder by RLS) works with the SSI protocol. I connected the Clock wire to a Digital Output Pin and the Data ...
0
votes
0answers
30 views

How to create a slideshow like program using c? [on hold]

I'm a beginner and I'm trying to make a program where it calculates body-mass-index and displays their category i.e. overweight, underweight etc and gives them a diet plan accordingly so here's what I ...
0
votes
0answers
64 views

Why is negative of a double number not working properly in C? (a = -a)

I am writing a C code to filter out an ECG signal using a Highpass filter after lowpass filtering the original ECG signal in real time. I am using buffers(arrays) of type double for each stage of the ...
1
vote
2answers
37 views

Best way to pass a string array to a function imposing const-ness in all levels down

In C we cannot assign a char** to const char *const * because of this problem. So, what's the base way to declare a function accepting an array of strings? My input parameters may be of any types, ...
-5
votes
0answers
40 views

Cloud based compiler for C Programming [on hold]

I am trying to develop an android app/game to learn C on Android Studio and so far I'm stuck with the compiling of code. I am currently making users input text and I make string comparisons to check ...
-4
votes
0answers
37 views

COSH in power series(?) [on hold]

I need to write a program that will count value of cosh in power series for given values from xp to xk and they will be different by some k. And all of these stuff should be shown as a table.
1
vote
0answers
33 views

what is the signal sent by OS when date and time change happens in linux [duplicate]

I have written an application program and what to get notified in this application if system date or time changed, the same way if user presses ctrl+c then OS sends sigkill signal. My requirement is ...
-3
votes
0answers
20 views

Minimal setup for a microcontroller with gsm, gps and motion sensor [on hold]

I am searching for a minimal hardware setup in point of money and size for a microcontroller with gsm, gps and motion sensor. Does anyone have a suggestion for suitable hardware?
-2
votes
0answers
26 views

Data Decode Task [on hold]

Can anybody please help me to solve the task below in the image file? Data decode task Your help would be really appreciated. I just need to have some hints to start as I am a new embedded ...
1
vote
0answers
24 views

libbpf: Error loading ELF section .BTF: 0

I got this error message on ubuntu 19.04 when I try to execute sudo ./mineonlyret which is the user space program which loads an ebpf program and it is described after. I tried the same configuration ...
0
votes
2answers
75 views

how can i modify the threads to print “ hello world again” ? in C

how can I force the three threads to print " hello world again" using lock_mutex or sleep function ? im done with it ... /* t2.c synchronize threads through mutex and conditional variable ...
-2
votes
0answers
40 views

Can't include `dbghelp.h` while compiling on Windows

I'm writing a C application on Windows 7, and it uses the Windows C API. [Edit] I'm using Mingw. I have no problems including <windows.h> and using WinAPI functions. However, I would like to ...
0
votes
0answers
21 views

Cython: convert a C struct (with not only simple types) to a Python object [duplicate]

For a project I need to modify a part of sklearn source code and I ran into some issues using cython library. I have a C struct defined as: cdef struct split_info_struct: # Same as the SplitInfo ...
7
votes
1answer
94 views

Why does my program keep getting stuck while running the mandelbrot brainf*** program?

I wanted to improve my C skills, so I search some program's ideas. Someone propose to create a simple Brainf*** interpreter and then a compiler. So here I am. I created the interpreter and it works ...
0
votes
3answers
43 views

Why can't I get the correct value of structure pointer?

I would like to use the ptr[1]->ReadLength in the function, but it always display 0. What the method to solve this problem? Thank you. struct cache_read_block { unsigned short ReadLength; // ...
0
votes
2answers
50 views

Using strtol to parse integral data and avoid invalid formats - C

So I want through the most topics related to using strtol in respect of inputs, but didn't find the exact issue I look for. Basically, I have to build some data structure in C (m-ary tree), and we ...
0
votes
0answers
36 views

How to force GCC to generate specific floating-point instructions [duplicate]

Given the following C code, double a = 4.00; double b = 123.456789; double c = 15.123; double res = a*b + c; return res; compiling with riscv64-linux-gcc -g -o2 generates the ...
0
votes
1answer
43 views

Create a function that takes a structure (or a pointer to the structure) as parameter and sorts the names in alphabetical order

I create a structure with 3 names,and I want to create a function that takes a structure (or a pointer to the structure) as parameter and sorts the names in alphabetical order. I don't know how to fix ...
0
votes
0answers
19 views

php-src - ZEND_TSRMLS_CACHE_UPDATE - what is it and when it is needed?

What is the ZEND_TSRMLS_CACHE_UPDATE directive in php/ext skeleton? http://github.com/php/php-src/blob/92ac598aabd336593a47ed3959f1031674b763e6/ext/skeleton/skeleton.c#L52 When and why is it needed?...
-2
votes
2answers
82 views

Is there a solution to detect memory error in a C program?

I'm coding C lib functions and have a problem about the memory. For the strcpy() function: char *my_strcpy(char *str1, char *str2) { int i = 0; for (; str2[i] != 0; i++) str1[i] = ...
0
votes
0answers
16 views

How to create multithreaded HTTP client in C for the following server code [on hold]

I am unable to make my HTTP client as multi-threaded. The code for the multi-threaded HTTP server is below. Kindly share the right way to execute the code below: http://github.com/ozgurhepsag/Multi-...

返回首页
杏彩计划 杏彩官网 杏彩APP 杏彩走势图 杏彩下载 杏彩官方 杏彩网站 杏彩怎么玩 杏彩官方 杏彩靠谱吗 杏彩代理 杏彩骗局 杏彩投注 杏彩倍率 杏彩开奖 杏彩漏洞