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.
I am trying to implement a simple queue using a dynamically allocated array. This queue is part of the FIFO queue I am building for the FIFO page replacement algorithm
long *queue;
void add_end(long ...
There are certainly some differences between a macro and a function
But I want to know that is it okay that we say that macros in c/c++ are same as script in MATLAB?
The difference between macro and ...
During the disassembly process, i can obtain the function location as a virtual memory address.
How do I convert a virtual address to a physical file location?
Please refer to the image below.
...
In C, I am trying to free all memory in a singly-linked list, the structure of which is:
typedef struct node {
char *data;
int weight;
struct node *next;
} Node;
The last element has a next ...
I want to make sure that I have done correct according to the given question. the question is to make a simple series of programs that prints to the screen the following string - "I love OS ...
asked 45 mins ago
Awani
17111 silver badge99 bronze badges
I am creating a Linux type shell program for a school project. So far I have implemented the basic Linux external commands like "ls","ps", etc., using execvp and basic pipes. As ...
If I am using void numberToBinary(int binaryArr[], int numberOfElements) to convert a number to a binary number how would I go about doing that? I tried a code I used from an earlier lab, and it did ...
One of the differences between a pointer and an array is that an array is static whereas a pointer is dynamic meaning you can resize the memory allocated. Can someone demostrate this with an example I ...
I have been trying to figure out how to write producer.c and consumer.c where two classes share one table to produce and consume respectively. The program should compile and run as followed.
$ gcc ...
int main()
{
int i;
int status;
for (i = 0; i < 4; i++) {
if(fork() == 0){
sleep(1);
}
}
printf("This is the end.\n");
...
I'd like to encrypt in a C/C++ Linux program data that is received from stdin to a Curve25519 public key (32 byte).
cat file.bin | ./my-program ...
Let's say I want to read a file where each line has a string, and when there is a new line or the end of the file, I print the number of characters read. For example,
abcdf
asd
sdfsd
aa
This would ...
Hi I am coding a raspberry Pi to light up 5 LEDS for a binary number. I am missing some code because I am not sure what to put there, and my output is not coming out correctly. My output is below
How ...
I'm trying to solve the problem sets of CS50.
Task is, to recover jpegs from data.
My code produces jpegs, but it seems to take just one chunk of 512 bytes instead of the whole picture.
Does my "...
For a project, I had to find the individual 8-bits of a unsigned int. I first tried bit-shifting the mask to find the numbers, but that didn't work, so I tried bit-shifting the value and it worked.
...
I need help with a recursive algorithm (function) given the following set of rules:
If m is even then return m = m/2
If m is a multiple of 3 or 4 return the subtraction of the multiplication of the ...
I want to create a structure so that the float would always wrap between two values. (These would be static inside the structure)
For example, if I want an angle structure that wraps between 0 and 360....
Here is a program to find the sum of the rows.
The task : Determine the maximum modulus term of the series and compare the calculation error with the grid step for it.
#include <stdio.h>
#...
I try to create a process tree according to the values that are in my array.
So that for each process its number of children will be the number found in this cell in the array.
So I kept a number that ...
I have a function to search a BST with a string the user inputs and print the names of any nodes that match it, but I can't get it working properly, it seems to be finding a string in the array that ...
For example, i have the array:
char emails[30][80];
the only way to set a value on it is by adding the code line:
strcpy(emails[0], "String Value");
if i use
emails[0] = "String Value&...
void initTimer (void);
void delay (unsigned long milli);
void main (void)
{
//initialize peripherals
initTimer();
//PORTB all outputs
TRISB = 0;
LATB = 0;
TRISA = 0x0F;
ANSA = 0;
...
I'm using elementary OS 5.1.7 Hera (based on Ubuntu 18.04.4 LT) I created a very simple c programme:
#include <stdio.h>
int main()
{
printf( "Hello World!\n" );
return 0;
}
and ...
asked 5 hours ago
navy1978
1,11811 gold badge1111 silver badges2626 bronze badges
I have to write a C code so that the RGB LED on the board breaths. My code is blinking not breathing. My teacher said that varying brightness is achieved by varying duty-cycle so in that case I can't ...
I am a beginner in C, and i am trying to draw a diamond like shape with the number of stars as below
top-1,2,4,7,10,13,16 bottom-14,11,8,6,3,1 but i have failed to come up with the logic to accompany ...
I wrote this code but If condition doesn't work it always print one statement and ignore all in else if . This is the question:
Develop an online shopping management system for LXM company. Below is ...
I am making a program in c using if else conditions and it is running perfectly fine without any errors but it is not running the else condition(i.e. even if I am giving it the input where the else ...
my question is when I run the code the loop goes on infinitely. the expected output is to print hi 5 times then go to a new line and print 4 times the 3 and so on I cant understand what is causing the ...
I get an error when using the pow function -nan(ind) prints to the screen. Wondering if theres a way to use pow with numbers that have negetive bases and non integer exponents.
Currently the pow ...
This code prints question mark with white filled block.
What is the ASCII code here? I do not find it in the table. Thank you!
#include <stdio.h>
int main()
{
int i = 650;
printf(&...
I have a function in which I'm given the desired int index and a long* pointer to the array and I have to return the value stored in that index. The size of the array is 4 and each block has 16 bits. ...
I can't seem to figure out what is causing this problem. I am on a virtual machine with Ubuntu and using Geany to code. Everything should be right however, it still pops up, so do I run out of memory ...
Now when I type in a number is keeps saying it is out of range and binary is not showing up. Below is my output. I am trying to get it to show the binary of any number.
How many bits? 5
Enter the pin ...
I'm trying to print something like:
Exiting...
into a terminal when the program ends, but the way I want it to be outputted to the terminal is each dot after "Exiting" needs to be printed ...
I have a problem with this program in C. In a nutshell I have to send the data created by a sensor, through an aggregator. The aggregator, through a writer thread, read the value generated by the ...
I state that I'm a newbie of C programming. I have to solve this "easy" C exercise.
The program has in input two chars. These chars must be a numeric value between 0 and 9. I have to sum the ...
My yacc parser is showing syntax error even though the syntax is as per grammer.
my Yacc code:
%{
void yyerror (char *s);
#include <stdio.h>
#include <stdlib.h>
#include &...
In the Linux terminal, I want my C program to set the cursor at a certain position. The input prompt should look something like this for the user:
INPUT: I
Where I is supposed to be the cursor where ...
I know similar questions have been asked, but it's still unclear to me.
I have written a library with multiple drivers and modules for Zephyr RTOS. Now I would like to share part of that library with ...
Hello everyone today my question is "How Javascript scope works in memory ?"
DISCLAIMER:i'm talking about low level and some C concept
How Javascript knows under the hood the scope we are at ...
im trying to make a function to delete a specific line from a .txt file. basically at the end im using remove() and rename() to delete the .txt file and rename the 2nd .txt file that created with the ...
How can I create a progress bar in C which uses unicode character and works on Windows, MacOS and Linux?
I am trying to do something like in this post :
https://mike42.me/blog/2018-06-make-better-cli-...
I am trying to understand the llvm optimization. I do this by writing C code and converting into LLVM IR and reading produced code. Now as far as i understand, phi node needs the return of the block ...
I'm trying to generate a RSA key pair in C with the following function:
int generate_key(const int bits, char* public_key_name, char* private_key_name){
int ret = 0;
RSA *r = NULL;
BIGNUM *...
I remember talking about how the stack memory addresses grows down and the heap's grows up, but they occupy the same strip of memory. If that is the case why do some large data structures causes a ...
I want to include an external library called "raylib" on Dev-C++. I downloaded the library with .zip extension from github and tried to install it with Dev-C++ package installer, but it ...
There are 3 files:
struct.h:
typedef struct weight_sensor_str
{
uint16_t min_value, max_value;
uint8_t coeff_percent;
}weight_sensor_t;
extern weight_sensor_t front_sensor;
struct.c
...
asked 9 hours ago
Sheep
4911 silver badge77 bronze badges
typedef enum
{
ONE = 1,
TWO = 2,
THREE = 3
}Count_t;
typedef enum
{
RED = 0,
BLUE = 1,
GREEN = 2
}Color_t;
typedef struct
{
Count_t Count_en;
Color_t Color_en;
}Grp_t;...
asked 9 hours ago
Tinchu
9111 silver badge55 bronze badges
I am trying to use stacks with linked lists to convert an infix expression to a prefix expression. Here is my code for the same:
#include <stdio.h>
#include <stdlib.h>
#define M 100
...
I am trying to create a function to delete a certain node if its value matches the value entered by the user. I created a case if there is only a single node, but after deleting the node with free(...