07/09/19

Why is logical space in a 32-bit system specified in bytes rather than bits?

It is claimed in my textbook that in a 32-bit system, The instruction LDR r4,[r6] lets you address a logical space of 4GB.I know where the 4GB comes from, It is simply 2^32 / (1024 x 1024 x 1024).... more
C

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
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
C

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/18/19

How to append one file to another in Ubuntu Linux?

I have two files: `file1` and `file2`. How do I append the contents of `file2` to `file1` so that contents of `file1` persist the process?

05/16/19

How do I copy folder with files to another folder in Unix/Linux?

I am having some issues to copy a folder with files in that folder into another folder. Command `cp -r` doesn't copy files in the folder.
C

05/10/19

Effects of the extern keyword on C functions?

In C, I did not notice any effect of the `extern` keyword used before function declaration.At first, I thought that when defining `extern int f();` in a single file **forces** you to implement it... more
C

05/05/19

How come an array's address is equal to its value in C?

In the following bit of code, pointer values and pointer addresses differ as expected.But array values and addresses don't!How can this be?Output my_array = 0022FF00 &my_array = 0022FF00 ... more

05/04/19

How do I know the script file name in a Bash script?

How can I determine the name of the Bash script file inside the script itself? Like if my script is in file `runme.sh`, then how would I make it to display "You are running runme.sh" message... more
C

04/10/19

What does "static" mean in C?

I've seen the word `static` used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)?
C

03/29/19

How do you pass a function as a parameter in C?

I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?
C

03/27/19

How does free know how much to free?

In C programming, you can pass any kind of pointer you like as an argument to free, how does it know the size of the allocated memory to free? Whenever I pass a pointer to some function, I have to... more

What is an invariant?

The word seems to get used in a number of contexts. The best I can figure is that they mean a variable that can't change. Isn't that what constants/finals are for?

When, if ever, is loop unrolling still useful?

I've been trying to optimize some extremely performance-critical code (a quick sort algorithm that's being called millions and millions of times inside a monte carlo simulation) by loop unrolling.... more

How to always round up to the next integer?

I am trying to find total pages in building a pager on a website (so i want the result to be an integer. I get a list of records and i want to split into 10 per page (the page count)when i do... more
C

03/16/19

How do I check if an integer is even or odd?

How can I check if a given number is even or odd in C?
C

03/16/19

strdup() - what does it do in C?

What is the purpose of the `strdup()` function in C?

03/15/19

Adding elements to a sorted array?

What would be the fastest way of doing this (from an algorithmic perspective, as well as a practical matter)?I was thinking something along the following lines.I could add to the end of an array... more
C

03/15/19

How to escape the % (percent) sign in C's printf?

How do you escape the % sign when using `printf` in C? printf("hello\\%"); /* not like this */
C

03/15/19

Why does sizeof(x++) not increment x?

Here is the code compiled in dev c++ windows: #include int main() { int x = 5; printf("%d and ", sizeof(x++)); // note 1 printf("%d\ ", x); // note 2 return... more

03/15/19

How do I grep recursively?

How do I recursively `grep` all directories and subdirectories? find . | xargs grep "texthere" *

11/16/18

What is twelve less than the sum of 23 and m

How to run "hello, world!" assembly language program?

How do I assemble, link, and run the "hello, world!" assembly language program, and get the output using these steps:  1)  as testme.s -o testme.o2)  gcc testme.o3)  ./a.out   I am new to this... more

could anyone tell me whats wrong in this code?

#include<conio.h>#include<stdio.h>#include<string.h>static int i=0;struct web{char name[30],pass[30];}w[99];int n;void login(void);void reg(void);int main(){clrscr();printf(" ... more

I need help with several questions

1. What is the difference in the meaning between x3 and x[3]?   2. For the declaration:   int list[8];   How many memory cells are allocated for data storage? What type of data can be stored... more

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

Ask a question for free

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

OR

Find an Online Tutor Now

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