c

how to solve unhandled exception error when using visual C++ 2008?

Hi, Could someone please help me to solve unhandled exception error when using visual C++ 2008? the error is displayed as follow: Unhandled exception at 0x00411690 in time.exe: 0xC0000005: Access violation reading location 0x00000008 Some details: - tm 0x00000000 {tm_sec=??? tm_min=??? tm_hour=??? ...} tm * tm_sec CXX0...

Strange behaviour with fputs and a loop.

When running the following code I get no output but I cannot work out why. # include <stdio.h> int main() { fputs("hello", stdout); while (1); return 0; } Without the while loop it works perfectly but as soon as I add it in I get no output. Surely it should output before starting the loop? Is it just on my system? Do I...

Why does gcc add symbols to non-debug build?

When I do a release build with gcc (i.e. I do not specify -g), I still seem to end up with symbols in the binary, and have to use strip to remove them. In fact, I can still breakpoint functions and get backtraces in gdb (albeit without line numbers). This surprised me - can anyone explain why this happens? e.g. #include <stdio.h> sta...

Calling msi file in c from CreateProcess

Is there any option to call msi file from CreateProcess in c language in window OS. ...

C: Global ,Static variables understanding

Hi All, In following program . I have one doubt. I have declared one global variable . I am printing the address of the global variable in the function . It is giving me same address when I am not changing the value of global . If I did any changes in the global variables It is giving me different address why...........? Like tha...

Why the output for "a" is -80?

#include<stdio.h> #include<conio.h> #define ABC 20 #define XYZ 10 #define XXX ABC - XYZ void main() { int a; a = XXX * 10; printf("\n %d \n", a); getch(); } I thought the output should be 100 but when i saw the result i found o/p as -80. when i put bracket as #define XXX (ABC-XYZ) then i get output as 100 but wi...

Is it possible to use DOS commands in my ANSI C programs?

i want to use the dos commands in my ansi-c program how can i do so what type of lib or .h i will need for it if it is possible ? ...

unable to return 'true' value in C function

If Im trying to check an input 5 byte array (p) against a 5 byte array stored in flash (data), using the following function (e2CheckPINoverride), to simply return either a true or false value. But it seems, no matter what I try, it only returns as 'false'. I call the function here: if (e2CheckPINoverride(pinEntry) == 1){ PTDD_PTDD1 =...

Design Principles, Best Practices and Design Patterns for C (or Procedural Programming in general)?

Are there any known design principles, best-practices and design patterns that one can follow while designing a C project? Or useful design principles for procedural (imperative) programming in general? (I'm child of the 'object-oriented generation' and have to design a large C project for the first time) ...

Dynamic memory inside a struct

Hello, I'm editing a piece of code, that is part of a big project, that uses "const's" to initialize a bunch of arrays. Because I want to parametrize these const's I have to adapt the code to use "malloc" in order to allocate the memory. Unfortunately there is a problem with structs: I'm not able to allocate dynamic memory in the struct...

error in C++, what to do ?: could not find an match for ostream::write(long *, unsigned int)

I am trying to write data stored in a binary file using turbo C++. But it shows me an error could not find an match for ostream::write(long *, unsigned int) I want to write a 4 byte long data into that file. When i tries to write data using char pointer. It runs successfully. But i want to store large value i.e. eg. 2454545454 Which ...

#include headers in C/C++

After reading several questions regarding problems with compilation (particularly C++) and noticing that in many cases the problem is a missing header #include. I couldn't help to wonder in my ignorance and ask myself (and now to you): Why are missing headers not automatically checked and added or requested to the programmer? Such feat...

How to assign void* pointer1 to void* pointer2? Facing some problem

void* ptr1 = NULL; void* ptr2 = ptr1; unsigned int *buf = data;//some buffer //now ptr2 = buf + 8; The above change in address of ptr2 is not reflected in ptr1. I am trying void* ptr2 = &ptr1; too. Please let me know whats the mistake here. ...

Is fwrite non-blocking?

Before calling fflush can I consider fwrite to be = a non-blocking write? If not, why not and what are my alternatives? ...

how to use localtime function with VIsual Studio C++ 2008

Hi I am getting this error : "Unhandled exception at 0x00411690 in tim.exe: 0xC0000005: Access violation reading location 0x00000008" when I execute a program this is compiled and linked successfully and the problem is that localtime() function is not correctly recognized by Visual C++ 2008. (With VC++6, this program works fine). ... ...

Get the system display color settings

Is there a windows API to get the number of colors currently set on the display settings? What I mean is, if you look at the windows display setting you might get something like: resolution: 1280x800 colors: 1,000,000 I am using a call to WMI (Win32_VideoController) and get them from there, but I can't use this since the program cannot...

forks in C - exercise

I try to repeat and learn more advanced uses and options when cutting trees with forks in the jungle of C. But foolishly I find an example which should be very easy as I have worked with forks before and even written some code, but i can't understand it fully. Here comes : main() { if (fork() == 0) { if (fork() == 0) { printf("3...

Breakpoint when variable takes on a certain value.

I have something analogous to the following code... void function(int x) { // complicated operation on x blah blah } It all appears to be working fine except when x happens to be a particular value, say "273". But x being 273 is a rare event, 99.999% of the time it is some other value. Now I wish to observe the events whe...

Unknown error in the memory in C

I have a 2D dynamic array. I enter a line of 0's after line which has a biggest number: void InsertZero(int **a, int pos){ int i, j; a = (int**)realloc(a, n * sizeof(*a)); a[n-1] = (int*)calloc(n, sizeof(**a)); d = 0; for(i = n-1; i > pos; i--){ for(j = 0; j < n; j++){ a[i][j] = a[i-1][j]; ...

how to use gettimeofday() or something equivalent with Visual Studio C++ 2008?

Hi, Could someone please help me to use gettimeofday() function with Visual Studio C++ 2008 on Windows XP? here is a code that I found somewhere on the net: #include < time.h > #include <windows.h> #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 #else #define DELTA_EPOCH_I...