Skip to main content

All Questions

Tagged with
1 vote
1 answer
33 views

_Generic Statement For An Enumerator (Enum)?

I frequently have to deal with the functionality of enums in C. However, there doesn't seem to be an easy & equally efficient way of supplying a different result based off of a predefined enum ...
Zenais's user avatar
  • 96
2 votes
1 answer
99 views

Is There a Pragmatic Solution to Remove Enum Switches?

The title of this question is a little strange-sounding, but I could think of no better way to word it. My problem is this; I have a type inside a project called AmbiguousType, which is a union in ...
Zenais's user avatar
  • 96
-1 votes
1 answer
120 views

The implementation of a switch-statement in ARM assembly seems too minimal

I was learning about how switch-statements work under the hood in C, so I decided to look at the compiled code. From what I understand, C uses a jump table to implement switch-statements. However, I ...
AsianDora's user avatar
0 votes
1 answer
63 views

Immediate break after input using switch or if

I am learning C right now and im at the very beginning. Here's my code: #include <stdio.h> int main (){ char operator; double num1; double num2; double result; printf("\n Enter an ...
Bunyamin Erkaya's user avatar
1 vote
0 answers
61 views

Differences in Compilation Results Between GCC and Clang

I encountered a situation where my C code compiles successfully with GCC but generates errors when compiled with Clang. Here is my C code: #include <stdio.h> #include <stdlib.h> #include &...
Konvt's user avatar
  • 63
0 votes
1 answer
49 views

Calculation of income tax owed is not working correctly

this program will calculate your tax bracket by the entering your income and your marital status, s for single and m for married. The program will prompt you to enter income, then marital status. ...
user23760512's user avatar
2 votes
2 answers
127 views

Runtime cast of void pointer

I'm writing a C program that applies a different type of quantization to an array depending on an environmental variable. The problem is that, I need to use the same function void foo(void* ptr, ...
Saverio Pasqualoni's user avatar
0 votes
1 answer
265 views

Seeking Cython Optimization for Conditional Branching: Is There an Equivalent to switch?

I am currently working on a Python project that I need to rewrite in Cython to enhance performance. In this Python code, there is a segment that uses a series of if/elif statements to determine the ...
maplemaple's user avatar
  • 1,435
1 vote
1 answer
68 views

Nested switch statment using X-macros

#define LIST_D1(val, mask, _lc, _UC, comment, parentDictId) \ __BTN(val 1, mask ~0, _lc##cred_amazon_mws_token, _UC##CRED_AMAZON_MWS_TOKEN, comment N_("Amazon MWS Auth Token"), ...
Nabz C's user avatar
  • 568
0 votes
4 answers
98 views

How do I break out of a while loop from within a switch in an if else statement in C?

I was trying out simple activities about if statements, switches, and loops while studying programming and I ran into this problem. while (1) { if (/*condition*/) { //error } else { ...
Chlaus's user avatar
  • 11
0 votes
1 answer
57 views

Calculating the geometric series with different values in C but my outputs for some values are huge

I have written code in C to calculate the geometric series for three different cases. The values for the three cases are as follows. case 1: n=10000,a=2.0,r=0.01. Case 2: n=500,a=0.01,r=1.1. Case 3: n=...
Nick's user avatar
  • 401
1 vote
1 answer
58 views

Tokenizing a string inside a switch statement - C

I've been having a lot of trouble using strtok in a switch statement . Here's the code int main(int argc, char *argv[]) { char phrase[256]; printf("type a phrase to examine\n\n"); ...
imaginary flower's user avatar
0 votes
0 answers
55 views

How can a foor loop with an array index be 3x slower then a switch case into a function that does the same thing?

I was benchmarking function pointers vs switch case statements in quick-bench and got the expected result. Function pointers are slower than switch case. But I wanted to remove the operation from the ...
Even Elshaug Almås's user avatar
0 votes
2 answers
139 views

declaring switch statement and then calling it later

I've developed a code that creates concentric rectangles of alphabets based on the input, unfortunately as there's no dictionary function in C, I've used switch statement to convert my numerical value ...
Anubhav Shriwastava's user avatar
0 votes
0 answers
55 views

switch case performance and probability [duplicate]

I am writing a c string parser and i want it as fast as possible. I know that in the stream certain occurance of characters could (will) be more probable than others, i could write an if else to ...
mystackoverflowpseudo's user avatar

15 30 50 per page
1
2 3 4 5
74