c

How similar are Python, jQuery, C syntax wise?

I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python? ...

Making gcc generate only machine code.

More specifically, I would like to produce a file that I can load into memory (for example with mmap) and then jump to the start of that memory to run the code. Ideally, I'd like the option of either making the code relocatable (which might be inefficient) or specifying an explicit address that the code expects to be loaded at (which is...

Floating point exception

i successfully complied the code: #include <stdio.h> #include <math.h> int q; int main() { srand( time(NULL) ); int n=3; q=ceil(sqrt(n)); printf("%d\n %d\n", n,q); if(n == 2) printf("%d\n is prime", n); else if(n % 2 == 0.0 || n < 2) printf("%d\n is not prime", n); else { int x;...

Is it possible to have source code that 'times out' (becomes invalid after a certain moment)?

We are currently busy migrating from Visual Studio 2005 to Visual Studio 2010 (using unmanaged C/C++). This means that about half of our developers are already using Visual Studio 2010, while the other half is still using Visual Studio 2005. Recently, I came into a situation where a certain construction can be written in a clean way in...

Passing and using variable number of arguments to function in C

I don't understand why this doesn't print out "this is a test 42" like I'm expecting it to? 1 #include <stdio.h> 2 #include <stdarg.h> 3 4 #define ME(x) blah x 5 6 void blah(const char *fmt, ...) 7 { 8 va_list arg; 9 10 va_start(arg, fmt); 11 printf(fmt, arg); 12 va_end(arg); 13...

TCP packages concatenated by libpcap automatically in C under windows??

I installed wireshark in my xp system which needs libpcap lib. Well, my program needs libpcap too.. But,when i capture in my c program, i found something very interesting.. I captured a http package, whose size is more 3000 bytes. but in my program, it takes only one loop, because every ip package take less than 1500 bytes, which means, ...

Can pointers behave as variable?

Hi, I have a confusion related to this program. #include <stdio.h> int main(void) { int value = 10; char ch = 'A'; int* ptrValue = &value; char* ptrCh = &ch; int* ptrValue1 = value; char* ptrCh1 = ch; printf("Value of ptrValue = %d and value of ptrValue1 = %d\n", *ptrValue, pt...

In the C source code of Ruby, where is the Ruby operator `=` defined ?

I'd like to read the logic code of =, but can't find it. UPDATE: I found the test_multi method text/ruby/test_assignment.rb. It's Ruby code, but seems will let me to the destination. The reason I want to check the code is find how it handles multi-assignment. Like a,b,c = [1,2,3]. UPDATE: I found keywords "MASGN" and led me to c...

Why no sanity checks in legacy strcpy()

Following is the most popular implementation of strcpy in traditional systems. Why dest and src are not checked for NULL in the start? I heard once that in old days the memory was limited so short code was always preferred. Will you implement strcpy and other similar functions with NULL pointer checks at the start now days? Why not? cha...

Extern Symbols in Object files

Hi, I am facing a strange issue, but unable to simulate it a smaller scale. The problem is my symbol table has an entry of my extern symbols. These are declared in a header file. Defined in some other file - header.c Header file header.h extern void rlog(int , char*, ...); extern int SetGDebug(string); extern int GDebug; test.cpp C...

Why mkdir fails to work with tilde (~)?

When I write mkdir("~/folder1" , 0777); in linux, it failed to create a directory. If I replace the ~ with the expanded home directory, it works fine. What is the problem with using ~ ? Thanks ...

Caching performance of serial vs padded data

I got some objects with certain values, for example: (1) struct massPoint { double pos; double vel; double acc; } objects[LOTS]; or the same in arrays: (2) double pos[LOTS]; double vel[LOTS]; double acc[LOTS]; First question: Is it right if i call (1) padded data and (2) serial data? Second question: If i do some oper...

maximum and minimum in c

to find minimum and maximam number ...

How to use select() in chat client program in C socket programming ?

I'm newbie. I want to make the client program to receive input from keyboard and data from server. I don't want if while user type something (scanf) and its block to receive data from server. How to write the code in C ? Thank you. ...

What happens with memory usage after exec*()

C parent program does some processing and allocates memory, then calls execvp(). What will happen with all the allocated but not freed memory? Is it automatically freed or stays as a garbage? ...

In which language is Chromium OS written?

I wonder on which language is Chromium OS written.I guess they have used C/C++ but did they put something different(Go,).Did they used Assembly for low level code as I know that they had to change some things to make booting a lot faster? ...

determine file permissions for the current user

I am looking for a way to determine file permissions for the current user (i.e. the process's UID) on POSIX-compliant systems. I don't want to try opening the file - that could get messy with directories and all kinds of special files. I am compiling a directory listing of a specified directory, and for each file, reporting a bunch of t...

Segmentation fault when increasing array size

Hi, I am writing a C program. In the first lines, I have typedef float m_elem[NMAX][NMAX][3]; m_elem asa_m; m_elem asa_mi[100]; then, some calculations. At the moment, and for each run and depending on the input, I change on the code the NMAX value, and then recompile it and run it. For NMAX values below 500, the program runs ok, ...

UNIX cc executable location

When I compile a .c file using the cc command, it creates an a.out executable. I've noticed that it creates the a.out file inside my current directory. Is there a way to make the a.out file be created in the same directory as the .c file wherever I happen to be on the system? for example if my current path is ~/desktop and I type in t...

how to use struct in gcc?

I am of late working on gcc compiler. whenevr i m compiling my code, m encountering problem with declaration of structure. How to tackle this problem. Do i need to write the syntax differently in gcc?. if yes, how? please suggest something. ...