c

Is it possible to estimate the size a call function will need in the stack?

Hi, I am trying to understand a C code from another programmer. Sometimes I get segmentation faults and I think it could be due to stack overflow. I wonder whether in Visual Studio (or another way) is it possible to estimate in an easy way, given a call to a function, the size it will need on the stack when creating variables. Thanks ...

checked and unchecked exception in .NET

a strange idea comes to me when I'm reading APUE(Advanced Programming in UNIX Environment). It seems that in UNIX's error handling, it has 2 types of error(FATAL & INFATAL). I feel like it's something related to checked and unchecked Exceptions in JAVA. So, to sum up, in a program, you has 2 kinds of errors, one of them is critical and...

linked list memory diagram

struct letter { char ch; struct letter *ptr_next; } *ptr_first,*ptr_this; //ptr this contains the address of the first node and ptr this contains the address of last node added. A word chair has to be inserted in the linked list such that C goes into the first node,h in the second and so on.. The attached picture is the memory diagram ...

Can socket send / recv return errno 27 (EFBIG) on Solaris?

Can socket send / recv set errno 27 (EFBIG) on Solaris? Under which condition this happens? ...

ANSI C equivalent of try/catch?

I have some C code I'm working with, and I'm finding errors when the code is running but have little info about how to do a proper try/catch (as in C# or C++). For instance in C++ I'd just do: try{ //some stuff } catch(...) { //handle error } but in ANSI C I'm a bit lost. I tried some online searches but I don't see enough info abou...

* glibc detected * realloc(): invalid next size:

I have a problem with realloc function: *** glibc detected *** realloc(): invalid next size: Here is the relevant part of code: char* pathfile = NULL; int tcpargc=6; char *tcpargv[tcpargc]; int it; for (it = 0;it < tcpargc;it++) tcpargv[it] = NULL; ... while (1) { ... if (pathfile == NULL) ...

Is it possible to know which lines of the source code were executed?

Hi, I am debugging a C code with Visual Studio. There is a loop called 10000 times and in one of the interactions, at the end of the loop, there is an error, as the program tries to access the N+1 value of an array of length N. I want to go back and debug the origin of the error and I wonder if somehow Visual Studio, in debugging mode, ...

What is the faster ( and slower ) language to do this ?

Possible Duplicate: What is the faster ( and slower ) language to do this ? I want to know what is the faster ( execution time ) language for this simple script ( executed through ajax ): Pseudocode: // start code var str = GET['string'] INSERT SQL SELECT SQL // end code This is a very simple script with 2 simple query. ...

Signed right shift = strange result?

I was helping someone with their homework and ran into this strange issue. The problem is to write a function that reverses the order of bytes of a signed integer(That's how the function was specified anyway), and this is the solution I came up with: int reverse(int x) { int reversed = 0; reversed = (x & (0xFF << 24)) >> 24; ...

Purpose of C/C++ Prototypes

I was reading wikipedia on C/C++ Prototype statements and I'm confused: Wikipedia say: "By including the function prototype, you inform the compiler that the function "fac" takes one integer argument and you enable the compiler to catch these kinds of errors." and uses the below as an example: #include <stdio.h> /* * If this prot...

How do you read scanf until EOF in C?

I have this but once it reaches the supposed EOF it just repeats the loop and scanf again. int main(void) { char words[16]; while(scanf("%15s", words) == 1) printf("%s\n", words); return 0; } ...

How to declare a C array that takes up all free space in a memory section?

Assume I have a 128KB memory region. In my linker directives I split this region into three sections: .section_text .section_data .section_bss The size of each section is unknown pre-compilation, but I have constrained .section_bss to use all remaining space within the memory region after .section_text and .section_data are allocate...

Best Windows IDE to try out C programs

I had used Turbo C earlier. Is there any advanced IDE, like Visual Studio, so that I could brush up on C. ...

Obscure pointer declaration

Hi, I have a question which is in some way, I guess, completely trivial: what's that (and why)? const float *(*const*)(int) My understanding is that it is a "pointer to a constant pointer to a function taking an int as argument and returning a pointer to constant float". Is it correct ? How to "mentally parse" (*const*) ? Especiall...

Overflow with product of ints

In the code below, the value of prod is not 9,000,000; it gets a garbage value. Why do we need num1 and num2 to be of type long? #include <stdio.h> int main() { int num1 = 3000, num2 = 3000; long int prod = num1 * num2; printf("%ld\n", prod); return 0; } ...

Average execution time

Hi, is there any nice GNU way how to measure average (worst case, best case) execution time of some command line program? I have image filter, unspecified amount of pictures, filtering them using for-loop in bash. So far I am using time, but I can't find a way how to get some statistics. ...

Odd behavior with NSUInteger - can't convert to float properly

Here is my situation. Its driving me nuts: I have an NSMutableArray with a count value of 517. I have a double value that is my multiplier. double multiplier = 0.1223; double result = [myArray count] * multiplier; // 63 even (wrong!) In fact it should be 63.2291. If I go: double result = [myArray count] * 0.1223; // 63.2291 (right!)...

C Struct pointer as Parameter

I'm trying to pass a pointer to a struct in C but i cannot: float calcular_media(struct aluno *aluno) { Output warning: C:\WINDOWS\system32\cmd.exe /c gcc main.c aluno.c aluno.c:7:29: warning: 'struct aluno' declared inside parameter list What am I doing wrong? Thank you. ...

How do I read white space using scanf in c?

...

Why no "realloc" seems necessary when allocating new element to a char pointer?

I'm trying to create a pointer to char pointer to which I can easily add new elements (strings). I use malloc to create the first 2 dimensions and realloc when I want to add new items. I wrote code with and without realloc and I'm getting the same results. Is this an expected/normal behavior? With realloc: char **p; // create poin...