c

Klocwork & c - The number of lines of source code actually used.

Hi, My project is made out of lots of bits and pieces of older code. How do I know how many lines of code were actually used? Can Klocwork provide me this answer? I've noticed that Klocwork holds the number of line (SLOC) in the project - but is it the number of actual lines used - or can it include "dead code" areas? Thanks, Mos...

Complicated Windows desktop size increase

Hello, i want to increase desktop size (programically), effect should be like attaching second monitor, on the primary monitor nothing should change after increase. Such trick is needed to hide window off screen and then using PrintScreen get that window image, cutting it from whole screen. P.s. PrintWindow() function wont help here, ...

Reading/Writing self heap

Could the own heap space be readed? could the software be self modified in memory? I write some code to show the subject, am I reading own code at memory? how (if possible) to write it and change instruction on runtime? #include<stdio.h> #include<stdint.h> volatile int addressBase; uint8_t read(int address); int main(void) { ...

C - calloc() v. malloc()

Possible Duplicate: c difference between malloc and calloc Please explain the significance of this statement, Another difference between the malloc() and calloc() functions is that the memory allocated by malloc( ) function contains garbage values, while memory allocated by calloc( ) function contains all zeros...

rich edit class

HWND hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 0, 0, width, height, hWnd, (HMENU)IDC_MAINEDIT, GetModuleHandle(NULL), NULL); Well, that's how I create an (readonly) edit (textbox) control. How can I create a RichEd...

How to decode base64 in C ?

Possible Duplicate: How do I base64 encode (decode) in C? Hello All, Is there any way i can only decode the base64 string in C ? Thanks, Neel ...

How does "Puts()" function work without arguments?

I came across this piece of code on a website. main(i) { gets(&i); puts(); } This code compiles and runs fine! It gets a string as input from the user and prints it!!!! But, my question is, how? (note that puts() function does not contain any arguments!) ...

Find the permissions of a file in windows.

Hi, I work in Linux. In Linux with stat function, we can extract the permissions of a file. Similarly how can we extract the permissions of a file in windows. _stat function in msdn states that permission bits are set in the stat buffer. But it does not give how to extract them. http://msdn.microsoft.com/en-us/library/14h5k7ff%28V...

Lua C API and metatable functions

I'm using Lua inside a C application, and I have two tables. I want to create a third table that, while empty, will index values from my first two tables. I wrote the following simple example in Lua - a = { one="1", two="2" } b = { three="3", four="4" } meta = { __index = function(t,k) if a[k] == nil then return b[k] else return a...

File Redundancy in C

What is meant by "File Redundancy"?? It would also be helpful if a "C Program to detect File Redundancy" be also given. I was asked the above question in an Interview. I didnt know the answer to it since I could not understand what they were asking in the first place. Can anyone help me!!! EDIT : I have rephrased the question. I think...

How can I figure out what functionality is being used from what header?

I am porting a large project to Windows, and I'm stuck on unistd.h. I doubt this code is using a great deal of unistd's functionality, so I think I could be able to provide some sort of replacements for it. Meanwhile, I need to figure out what features of the header the code is using. Is there any tool that will tell you what features ...

C programming: is this undefined behavior?

Our class was asked this question by the C programming prof: You are given the code: int x=1; printf("%d",++x,x+1); What output will it always produce ? Most students said undefined behavior. Can anyone help me understand why it is so? Thanks for the edit and the answers but I'm still confused. ...

C: What will the statement 'return A || 1' return when A >1?

Although I wouldn't have written it myself, what is the expected result of the following statement where A (guaranteed to zero or positive integer) is greater than 1? return A || 1; In many languages, I would expect A to be returned, unless the value of A is zero, in which case 1 would be. I don't have my C book to hand, but I note ...

Understanding sizeof(char) in 32 bit C compilers

(sizeof) char always returns 1 in 32 bit GCC compiler. But since the basic block size in 32 bit compiler is 4, How does char occupy a single byte when the basic size is 4 bytes??? Considering the following : struct st { int a; char c; }; sizeof(st) returns as 8 as agreed with the default block size of 4 bytes (since 2 blocks are a...

c++ - pointer resistance

If *get_ii() returned heap memory, rather than stack memory, would this problem be eliminated? 01 int *get_ii() 02 { 03 int ii; // Local stack variable 04 ii = 2; 05 return &ii; 06 } 07 main() 08 { 09 int *ii; 10 ii = get_ii(); // After this call the stack is given up by the routine 11 ...

Compiling with GCC on windows 7: \mingw32\bin\ld.exe: cannot open output file a.exe

This is what I get when trying to compile a simple hello world program with gcc. c:\>gcc hello.c hello.c:9:2: warning: no newline at end of file C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot open output file a.exe : Permission denied collect2: ld returned 1 exit status Does it have something to do with w...

How do I resolve link errors that appear in Objective-C++ but not Objective-C?

Hi guys, I'm converting my App Delegate file from .m to .mm (Objective-C to Objective-C++) so that I can access a third-party library written in Objective-C++. In Objective-C, my app delegate builds and runs fine. But when I change the extension, the project builds and I get link errors, all of which are missing symbols from a static li...

reading double from binary file in c

hi, can anyone show how to correctly convert binary represented data into double value in C. for example, i have 8 unsigned char values to be converted to double value (let's name it buffer). so buffer[0]'s 0's bit is LSB, and buffer[7]'s 7's bit is MSB. thanks a lot in advance! ...

Serial port reading and writing with C

I am writing a C program that will read and write from/to a serial port. Each write will be followed by a read which will contain data based on the write. I will have about 16 different writes to perform, each followed by a read. I am still new to serial programming and am trying to determine how to approach this. Should the program blo...

In which cases is alloca() useful?

Why would you ever want to use alloca() when you could always allocate a fixed size buffer on the stack large enough to fit all uses? This is not a rhetorical question... ...