184 Answered Questions for the topic C

09/08/19

#### What could cause the compiler to return the error " undefined reference to Print' " ?

I've been working on this simple C project, trying to implement header, implementation, and makefiles. My professor provided the code for us to test, however whenever I use the "make hello3"... more

07/12/19

#### I would like to be able to compare values in one CSV with a nominal set of values in another?

I have been given the task of injecting faults into a system and finding deviations from a norm. These deviations will serve as the failures of the system. So far we've had to detect these faults... more

07/11/19

#### Casio Calculator Programming?

I am planning to buy a CASIO FX-9860GII for school, but I am really interested in programming for it. I looked everywhere on the internet but could not find anything. Is it possible to create... more

06/27/19

#### Determine the sign of a 32 bit int?

Using ONLY: ! ~ & ^ | + << >> NO LOOPS I need to determine the sign of a 32 bit integer and I need to return 1 if positive, 0 if 0 and -1 if negative. Any ideas? I first... more

06/27/19

#### #define macro for debug printing in C?

Trying to create a macro which can be used for print debug messages when DEBUG is defined, like the following pseudo code: #define DEBUG 1 #define debug_print(args ...) if (DEBUG)... more

06/26/19

#### How dangerous is it to compare floating point values?

I know UIKit uses CGFloat because of the resolution independent coordinate system.But every time I want to check if for example frame.origin.x is 0 it makes me feel sick: if... more

06/26/19

#### Valid, but worthless syntax in switch-case?

Through a little typo, I accidentally found this construct: int main(void) {  char foo = 'c';  switch(foo)  {   printf("Cant Touch This\ "); // This line is Unreachable ... more

06/26/19

#### Simulink: How to get a buffer size that can be changed in C code?

I'm using a buffer from DSP System Toolbox in my Simulink model and genereate C code with Embedded Coder. I would like to have some kind of a parameter or define for the buffer size in my generated... more

06/26/19

#### Digit-increasing number test?

A number is called digit-increasing if it is equal n + nn + nnn + ... for some digit n between 1 and 9. For example 24 is digit-increasing because it equals 2 + 22 (here n = 2). Actually, a friend... more

06/26/19

#### Rounding Number to 2 Decimal Places in C?

How can I round a float (such as 37.777779) to two decimal places (37.78) in C?

06/25/19

#### Why aren't programs written in Assembly more often?

It seems to be a mainstream opinion that assembly programming takes longer and is more difficult to program in than a higher level language such as C. Therefore it seems to be recommend or assumed... more

06/23/19

#### Check that triangle is right?

I'm trying to check if a triangle is a right triangle in C language. a, b and c are lengths of sides of some triangle. int is_right_triangle(int a, int b, int c) { return (a * a + b... more

06/23/19

#### Undefined reference to pthread_create in Linux?

I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/ #include <pthread.h> #include <stdio.h> #define NUM_THREADS 5 void... more

06/23/19

#### What is ultimately a time_t typedef to?

I searched in linux box and saw it being typedef to typedef __time_t time_t;But could not find the __time\\_t definition.

06/22/19

#### How can one print a size_t variable portably using the printf family?

I have a variable of type size_t, and I want to print it using printf(). What format specifier do I use to print it portably? In 32-bit machine, %u seems right. I compiled with g++ -g -W... more

06/22/19

#### 1 = false and 0 = true?

I came across an is_equals() function in a c API at work that returned 1 for non-equal sql tables (false) and 0 for equal ones (true). I only realized it after running test cases on my code, one... more

06/22/19

#### Why does the smallest int, −2147483648, have type 'long'?

For a school project, I've to code the C function printf. Things are going pretty well, but there is one question I can't find a good answer to, so here I am. printf("PRINTF(d) \ : %d\ ",... more

06/21/19

#### Can we implement a doubly-linked list using a single pointer?

I want to use a structure like: struct node { char[10] tag; struct node *next; }; I want to use the above structure to create a doubly-linked list. Is that possible and if yes, then how I can... more

06/21/19

#### Why do we need C Unions?

When should unions be used? Why do we need them?

06/20/19

#### Removing trailing newline character from fgets() input?

I am trying to get some data from the user and send it to another function in gcc. The code is something like this. printf("Enter your Name: "); if (!(fgets(Name, sizeof Name, stdin) !=... more

06/20/19

#### C: XNOR / Exclusive-Nor gate?

I am trying to find the most effective way of writing a XNOR gate in C. if(VAL1 XNOR VAL2) { BLOCK; } Any suggestions? Thanks.

06/20/19

#### How to initialize a struct in accordance with C programming language standards?

I want to initialize a struct element, split in declaration and initialization. This is what I have: typedef struct MY_TYPE { bool flag; short int value; double stuff; }... more

06/20/19

#### What do people find difficult about C pointers?

From the number of questions posted here, it's clear that people have some pretty fundemental issues when getting their heads around pointers and pointer arithmetic.I'm curious to know why. They've... more

06/19/19

#### Need help programming with Mclauren series and Taylor series?

Ok so here's what i have so far: #include <stdio.h> #include <math.h> //#define PI 3.14159 int factorial(int n){ if(n <= 1) return(1); else return(n *... more

06/15/19

#### find if 4 points on a plane form a rectangle?

Can somebody please show me in C-style pseudocode how to write a function (represent the points however you like) that returns true if 4-points (args to the function) form a rectangle, and false... more

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.