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
1
vote
0answers
5 views

How to show error message if I accidentaly run x86 binary on ARM?

In my project, we are building application to run on Linux both on x86 and ARM. Accidentally, I have run the x86 binary on ARM, and to my surprise the binary launched - sort of. It wrote one of the ...
0
votes
0answers
10 views

Simple question on pointers and how to initialize an array in C

I have a question on a simple program that i wrote to initialize an array one element at a time, the few lines of code are below: #include <stdio.h> int main(void) { int *ptr; int index; for (...
1
vote
0answers
23 views

How to printf the value of input by user multiple times

I'm doing my c assignment and I have faced some problems. One of it is that I can't printf the value that are retrieved from the user. The value retrieved is in for loop and for the output it only ...
0
votes
3answers
30 views

Does specifying array size for a user input string in C matter?

I am writing a code to take a users input from the terminal as a string. I've read online that the correct way to instantiate a string in C is to use an array of characters. My question is if I ...
0
votes
0answers
21 views

Is it a compiled library portable?

I have a conceptual question about writing a library in plain c. I have some functions that I have to use in different programs in the same folder, so I was thinking about writing a library to host ...
-2
votes
0answers
21 views

Installing other programs without visible installers [on hold]

How can I install other programs on Windows like the Visual studio installer does. Display the user that "We are installing this in background" and install some application on Windows in background. ...
-3
votes
0answers
34 views

Program using nested for loop? [on hold]

Comment ,answer will be appreciated... Thank you. Please don't give negative vote I tried the given code and got output as 1 12 123 1234 But I need output at right side #include <stdio.h> ...
0
votes
0answers
19 views

Conflicting types for 'safeOpen' on C [duplicate]

I really do not understand why this code does not works. Please, help! I m using C for it ///////////////////// /////////////////////////////////////////////////////////////////////////////////////////...
0
votes
0answers
14 views

difference between printf(“%d\t%d”,*p++,++*p) and printf(“%d\t%d”,++*p,*p++) [duplicate]

int main() { int a =10; int *p = &a; printf("%d\t%d",*p++,++*p); return 0; } output of above program is 11 11 but when printf("%d\t%d",*p++,++*p) is changed to printf("%d\t%d",+...
0
votes
0answers
27 views

Formating issues with some chars but fine with others

Having a couple issues with this calculator I'm trying to write. Not 100% sure if this is formating or something else. The first issue is that it will not print the results after use of + and -, C (...
-4
votes
3answers
27 views

Array not printing?

I'm trying to print an array of 100 numbers in 10 rows and 10 columns, each number is randomly generated by a random number generator within a certain range. However, either nothing is printed or a ...
-1
votes
0answers
13 views

Reading a signed integer from a file in C

I have to read " -10899 "(and many more integers) from a text file into an integer variable in C. This is what I have so far: int i = 0; // get data from file and convert to int for(; i < ...
0
votes
1answer
39 views

About a static value in function's parameter in C

what should be the output of this code below? and why? I am not sure if the int i declared in the main function acts like a local variable, or not. static int i = 3; void f(int*j){ j++; } int g(...
-2
votes
0answers
23 views

Filename.exe stopped working on running this recursive functon

This functions of counting Non leaf node is correct according to me but when I call it in the main function it says "Filename.exe stopped working"?? Can anybody help me out and tell me what is the ...
-2
votes
1answer
31 views

Declaration char * VS (char *) in C

I need to understand the difference between the two kinds of declarations: char *ptr ; (char *) ptr = ptr1;
1
vote
2answers
35 views

Using uninitialized variable without invoking undefined behavior

From 6.3.2.1 (emphasis mine) If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and ...
-2
votes
0answers
19 views

I need a theoretical exploitation for the following please: [on hold]

environment variables how they work where they are in memory wait when it waits when it doesn't what it really is for I'm basically new to C and I've been working around those concepts, but I need ...
0
votes
1answer
25 views

How do i “delete” useless , after scanf()

Here is a piece of my code : And output looks like: 12, 44, 55, I need to remove the last one ", " and i tried everything. while ((r = scanf("%d", &v)) > 0){ printf("%d", v); ...
1
vote
1answer
28 views

Array made with malloc function goes beyond desired size [duplicate]

I'm making a program capable to use some statistics functions. For that, I used malloc for the array that the numbers of the sample to operate on, as I want it's size to be based on users' input. It's ...
0
votes
3answers
35 views

How to set the level of precision for the decimal expansion of a rational number

I'm trying to print out the decimal expansion of a rational number in C. The problem I have is that when I divide the numerator by the denominator I lose precision. C rounds up the repeating part when ...
0
votes
0answers
27 views

how to make this program can accept the a word and h word but the h word is not repeatable

How to make this program can accept a word and h word but the h word can't be repeated. And if the string length of the x is bigger than the h print go else print no i tried to make this but it can ...
0
votes
2answers
33 views

C Program for calculating area & perimeter of a circle won't compile

Problem: When I try to compile the program I get 3 error statements, 2 of them are relating to using the pow math function to try and square the radius variable. The last error statement states that ...
0
votes
0answers
3 views

Scrollable layout in GTK3

I'm trying my hand at writing a C program using GTK (GTK 3 to be precise) (up to now, my experience has mainly been using ObjC, Visual Studio and so on but Cross Platform FTW!) I need to have a ...
0
votes
1answer
18 views

Why do I got a SIGFPE, Arithmetic exception error when I'm using a modulo on an int obtained by a modulo of a different integer in my code?

I'm trying to solve a problem in hackerrank but I got a SIGFPE, Arithmetic exception error when I tried to compile my code. After a few trial and errors, I figured out that the problem lies between ...
0
votes
1answer
11 views

ReadDirectoryChangesW not reporting last write events

I have managed to get ReadDirectoryChangesW() working for the folders I need to monitor. I am using the IO Completion routine and all of the change monitoring is done by a thread that does nothing ...
-1
votes
0answers
22 views

C ( Unix), problem with the die of a child process

i'm tring to write a interprocesses communication programm. In running, a child process dies by itself and the signal (SIGCHLD) it send to father is this: (i used a siginfo_t) si_code: 3 si_errno: 0 ...
-3
votes
0answers
27 views

how the ICQ and CCQ are vulnerable for Denial of Service Attacks (DOS)

how the ICQ and CCQ are in socket programming is vulnerable for Denial of Service Attacks (DOS)
0
votes
0answers
19 views

Retransmissions on Wireshark capture different from C program's

I wrote a C program that sniffs TCP packets (using libpcap) and stores them in a circular buffer. When the source_ip, destination_ip, source_port, destination_port and sequence_number of the just ...
1
vote
0answers
31 views

Fortran/C interoperability passing a struct from Fortran to C with allocatables

I am trying pass a struct from fortran to C, where the struct in Fortran has an allocatable. I would like to allocate the array inside a struct in fortran and read it in C. However, when I try to ...
0
votes
1answer
43 views

Bit ordering / Endianness flac decoding

I'm currently trying to write a FLAC to WAV transcoder as an exercise in C++, and I am currently struggling a bit the wording of the FLAC format regarding bit ordering. Here is the (little) section ...
1
vote
0answers
21 views

undefined reference for inline function [duplicate]

I have composed below small program to explain the issue, #include<stdio.h> inline void test() { printf("test inline\n"); return; } int main () { test(); return ...
0
votes
1answer
37 views

Printing character array [duplicate]

So I've been starting to learn C (coming from java) and tried implementing a concat function on my own So far I have this: #include <stdlib.h> #include <string.h> char* concat(char *...
-4
votes
1answer
36 views

Garbage characters when reading a file using fgetc

I'm trying to read a txt file UTF-8 encoding using fgetc and separate each line into words. I add each char to a string until I see a whitespace, and that makes a word. But every time I fgetc a char ...
-1
votes
1answer
41 views

to improve cache hit rate, How can I revise the program

Change the program to improve the cache hit rate and write the revised program. In addition, for the same cache (8word block size) in (a), compute the data cache miss rate. This is my assignment. ...
-1
votes
0answers
10 views

How to implement windows registry to activate my program after restarting windows explorer

I made a system call to add my program to windows registry When I search in Google I got that restarting the windows explorer will read all registry values and starts all the application registered ...
5
votes
1answer
52 views

How to create wrappers to library functions with original name?

I found this question very interesting: How to force compilation error if function return value is not checked? It's about enforcing compilation errors if you do not check the return value. I wrote ...
2
votes
1answer
25 views

Why does memcpy_s zeroize in the case of runtime constraint violation?

In this implementation of memcpy_s (as well as others) the region pointed to by dest is zeroized when a runtime constraint violation occurs. Can anyone explain why is this done? I got footguned by ...
1
vote
0answers
43 views

What is the concept of z = y + (y = 10) + y? [duplicate]

I was trying the following cases in C language but I got different values for rearrangement of expression. What is the concept? Please help Case 1: int y = 0; int z = y + y + ( y = 5 ); //...
0
votes
3answers
92 views

Output is 0 and not what i input

Hello i'm sorry if my question is too easy for you guys, i'm new to c and would like some help. Thank you This is my code #include <stdio.h> #include <stdlib.h> void swap2(); int main(){...
0
votes
0answers
39 views

QuickSort Crashing with 1 million integers [duplicate]

My code in C is crashing for 1 million numbers, i just can't seem to run it? I need the execution time for my assignment. It works with 100,000 integers but when i am changing it to 1 million it doesn'...
0
votes
1answer
20 views

Cant understand what happens when i run this code

I can't understand why the result of effe(10) procedure is 110. (Thats a code taken from an exercise) I tried to write down what is happening in the code, but there are too many recursions and i can'...
0
votes
0answers
9 views

ATMEL START with SAMV71Xplained ultra board, simple spi dma sending out-of-the-box example seems not to work

I'm using the ATMEL START framework for a while now and it worked great, but recently i encountered a problem with the SPI DMA. I'm using an oscilloscope to watch the slave select (SS), clock (SCK) ...
-9
votes
1answer
55 views

Any other way to write a loop for multiplication table to take run time values? [on hold]

To print multiplication tables, I'm using a for loop which has fixed values up to 10th times table only. I need multiplication table as run time values. Is there an alternate loop to take the values ...
0
votes
0answers
13 views

To store internal timer data in external eeprom using microcontroller Nuvoton N76e003

I am new to nuvoton N76e003.I want to store internal timer data i.e hours and minutes to external eeprom. In my project i have to store data sum of time for example :day 1 my timer work for 1 hour 30 ...
1
vote
1answer
57 views

Delete from double Linked List

I'm trying to delete a node from a doubly linked list but I have a problem and this problem is when the node is the first or in the middle it prints 0 instead and it's not really deleted , but it ...
0
votes
1answer
53 views

How do I loop over an array in a function in C?

I want to generate a 16 byte long unsigned char array and fill it with random chars except some. I am a noob in C still, and I still don't understand when to use pointers and such to correctly use ...
1
vote
1answer
30 views

Sending and Receiving different type of data using MPI_Isend

I want to send different type of data from a single node to another. For example, I have 2 data with different types: int and double. However, after I send them out, the node which receives the data ...
0
votes
2answers
54 views

how to concatenate two strings in while loop C

i'm using two txt files("names.txt", "fixes.txt") and need to read the words of these files line by line, and concatenate them in a new file("results.txt"). for example the names file contains this: ...
-2
votes
4answers
111 views

Why does the execution of a Java program take longer than the same program in C?

So I have 2 programs that do the same things, one written in C and the other in Java. They both create 50 threads and wait for all of them to finish, then terminates. In order to get a feel for the ...
-1
votes
1answer
27 views

Are there specific compiler flags to use gcc sync-builtins when cross-compiling for arm?

I'm trying to cross-compile a program that uses gcc builtins, specific __sync_val_compare_and_swap, __sync_add_and_fetch and sync_sub_and_fetch. Compiling works, but the linker is showing me the ...