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.
354,250
questions
0
votes
0answers
5 views
Why does the C preprocessor insert an extra space?
When I run the C preprocessor on this source file:
1+1 1-1
A+1 A-1
A+A A-A
#define A 1
A+1 A-1
A+A A-A
I get this output with clang -E -P:
1+1 1-1
A+1 A-1
A+A A-A
1 +1 1 -1
1 +1 1 -1
And almost ...
0
votes
0answers
3 views
Windows Memory mapping | Bytes change when mapped
I started a few weeks ago with learning about PE-structure and memorymapping of pe.
I think understand now the basics of this concept.
But then i realized something strange:
When i compared the binary ...
0
votes
2answers
33 views
Comparing a string with a struct member in C
I am attempting to create a small ticket pricing system. The user inputs the people accompanying them to the theme park as a command line argument (senior/adult/child/student) including themselves (...
2
votes
2answers
15 views
How do I make the program give the “Invalid Grade” message and ask for the grade to be entered again infinitely as long as the grade is >100 or <100
So in this C code the program will give an error message that says "Invalid grade" and it asks the user to enter the grade again if the entered grade is >100 or <0, but this only ...
0
votes
0answers
27 views
(it skip statements and output is every time else)
What is wrong here
(it skip statements and output is every time else)
#include<stdio.h>
#include<stdlib.h>
int main(){
float num,dm,cm,mm;
int units;
printf("program ...
0
votes
0answers
8 views
Getting “ERROR L127: Unresolved Exernal symbol” in C166
Currently, I am trying to compile an ancient operating system, after I had fixed several issues. The Problem I get now is that when my IDE (qVision) is trying to link the files, I get the error: "...
0
votes
0answers
11 views
OpenMP Search of a max parallel version runs slower than serial
I'm trying to parallelize a piece of code that has to do a LUP factorization.
In particular the Partial pivoting and the subsequent swap of the rows.
The problem is that the parallelize version runs ...
0
votes
0answers
28 views
Passing foo(int *) as argument to foo(void*) in X
A have a functions:
void somefunc(void func(void *)) { ... }
void foo(int *num) {...}
I'm trying to pass foo as an argument to somefunc but receive a warning.
What is the correct way to do this?
-1
votes
0answers
16 views
How get multiple key inputs at the same time on windows and in c [closed]
This probably has been answered but I haven't found a proper way to get multiple key inputs on windows and in c. I want a straight forward answer. No "wHeRe iS tHe cOdE?" and "wHy wOuLd ...
0
votes
1answer
20 views
Trying to figure out why my C program is only grabbing one of my repeated digits
I am writing a C program that will take user input and then print out what repeated digits were inputted.
#include <stdbool.h>
#include <stdio.h>
int main(void)
{
bool ...
3
votes
1answer
39 views
can not assign a 2-d array to struct in c
I'm writing a snake game. I have a structure which contains data of the snake, such as position of snake length etc. This is the snake.h file:
#ifndef SNAKE_HEAEDER
#define SNAKE_HEAEDER
#include &...
0
votes
0answers
33 views
Hand optimizing assembly code without the stack?
I am trying to hand optimize my assembly code for this multiplication function I have written in C.
long multiply(long x, long y) {
return x * y;
}
So far I have been able to get my assembly ...
0
votes
0answers
9 views
PWM Signals not generating correctly on stm32 f767zit
I am working with an stm32 f767zit and I am trying to generate PWM signals to control servos, but they are not generating correctly. I followedd the tutorial from here Deep Blue Embedded and was able ...
0
votes
1answer
39 views
Fifty Dice Game in C programming
I am having to write a C program to roll dice for two people. After the winner is determined, I need it to loop back around and ask to play again. If q is entered, the program will end. If user press ...
0
votes
0answers
32 views
Unexpected output due to printf() and scanf() [duplicate]
I implemented a C program where you enter a sequence of numbers separated with a space like 1 2 3 4 5. The program sees that the max time limit of entering each sequence is 15 seconds.
The code ...