The following little program is very awkward using GCC version 4.2.1 (Apple Inc. build 5664) on a Mac.
#include <stdio.h>
int main(){
int x = 1 << 32;
int y = 32;
int z = 1 << y;
printf("x:%d, z: %d\n", x, z);
}
The result is x:0, z: 1.
Any idea why the values of x and z are different?
Thanks a lot.
...
I am working on C firmware project. I have a union that is defined as,
typedef union {
unsigned long value;
unsigned char bytes[4];
} LONGVALUE;
I also have a function that has this prototype,
char sendHexToASCII_UART(char *msg, int cnt);
and a variable of type LONGVALUE defined as,
LONGVALUE countAddr;
THE PROBLEM:
I f...
The Tcp server need to serve many clients, If one client one server port and one server thread to listen the port, I want to know weather it is faster ?
If one port is good, could someone explain the different between one port and multiple ports in this case, thanks!
...
I have an assignment for class that I have to write a program to read and write key, value pairs to disk. I am using a linked list to store the keys, and read in values whenever I need to from disk. However, I am having trouble changing and deleting values. I am using this to test it: http://gaming.jhu.edu/~phf/2010/fall/cs120/src/sdbm-e...
Hi
As a Java programmer who wants to learn C, I try to create a command line based menu in C. The menu should read a line that is split by spaces that are divided into a matrix. Below are some Java code that does what I want: Can someone please help me to create a menu in C with this functionality?
while(scan.hasNextLine()) {
...
Possible Duplicate:
round() for float in C++
In cmath there is floor and ceiling, but I cannot find round. How does one round with the standard library without writing a function and dragging it around into all projects?
Thanks
...
I want to pass a pointer to a function. I want this pointer to point to some place in the middle of an array. Say I have an array like such unsigned char BufferData[5000];, would the following statement be correct syntactically?
writeSECTOR( destAddress, (char *)( BufferData + (int)(i * 512 )) );
// destAddress is of type unsigned long...
Hi !
I remember reading something about a formal specification language for C a while ago, but I can not find it now that I need it.
It was inspired by JML, using as far as I saw the same syntax.
The only reference to it I found is a paper, but what I am talking about was more polished than that.
If this rings a bell to you...
If n...
Possible Duplicate:
How do you write a basic operating system?
I want to create a basic operating system. Which can just boot up and I want to run a calculator in it. Though I am pretty good in maths, I am quite new to C programming. I have 28 days to complete the project. I am ready to slog day in day out. Is it possible to d...
How do i determine the first n digits of an exponentiation (ab).
eg: for a = 12, b = 13 & n = 4, the first 4 digits are 1069.
...
Are System.out, stdout and cout the EXACT same thing in Java, C and C++ respectively?
Why have three different names for the same thing (especially when C, C++ and Java have much in common)?
Also, I know what they are used for but what are they exactly, under the hood, I mean?
...
Context: I am not certain whether this is my problem or the problem of the server this is running on. I am trying to compile and run a small utility, to become a cron job, that uses the mysql libraries. The program compiles successfully with the following command, no errors or warnings:
gcc my_program.c -o my_program -I /usr/include/mys...
I am trying to use C/C++ (Preferably C) to enumerate the entire Windows registry, I was using recursion to do this but I keep running into stack overflows, which i understand but im unable to think of anyway to do this without recusion.
Advice on how to do this without recursion would be great, thx.
...
The standard C library functions strtof and strtod have the following signatures:
float strtof(const char *str, char **endptr);
double strtod(const char *str, char **endptr);
They each decompose the input string, str, into three parts:
An initial, possibly-empty, sequence of whitespace
A "subject sequence" of characters that repres...
I developed a process with some threads on a Linux machine (Ubuntu). I'd like to know how can i get LWP from each thread (using a glibc function), once the PID and PPID are always the same for all the threads of the process.
UID PID PPID LWP C NLWP STIME TTY TIME CMD
root 2588 2587 2588 0 11 00:05 ? ...
I am writing a C library which involves telling other computers on the subnet to send me messages. Therefore I must announce to them my IP address. This library should work on Linux, OS X and Windows. Currently I'm thinking mostly about the POSIX layer.
Given that a computer can have more than one address (for example if it has more ...
I make a distributed embedded application that will make use of several micro-controllers. The unit under control is a mechanical unit that I do not have, but I have a Simulink model of it. What are the possibilities to perform Model-in-the-loop testing of existing C code with minimum modification of it?
...
Hi all,
I am working on gcrypt library and want to generate public/private key pair in C under linux environment. I want to use S-expressions for this.
I have read the reference manuals which gives some idea about the functions which can be used but not very sure how to use it.
Can someone point me to good sources or some sample codes ...
Hello all,
I have this C function which attempts to tell me if a sub string is contained in a string.
int sub_string(char parent [1000], char child [1000]){
int i;
i = 0;
int parent_size = (int) strlen(parent);
int child_size = (int) strlen(child);
char tempvar [child_size];
int res;
res = 1;
while(i<(parent_size - ...
Hi,
I have two C static libraries libA and libB that I link against my executable E.
libA has a function that makes a call to a function that is in libB:
myLibAFunctionThatCallsAfunctionInLibB( ... )
{ libB_function(...); }
Both libraries compile fine. My executable E also compiles fine. E is compiled with gcc using -lA -lB flags ...