c

Where do I learn "what I need to know" about C++ compilers?

I'm just starting to explore C++, so forgive the newbiness of this question. I also beg your indulgence on how open ended this question is. I think it could be broken down, but I think that this information belongs in the same place. (FYI -- I am working predominantly with the QT SDK and mingw32-make right now and I seem to have confi...

faster strlen ?

Typical strlen() traverse from first character till it finds \0. This requires you to traverse each and every character. In algorithm sense, its O(N). Is there any faster way to do this where input is vaguely defined. Like: length would be less than 50, or length would be around 200 characters. I thought of lookup blocks and all but d...

Change BIOS settings using the C language

I was wondering if there is any way for me to write a C program to change the amount of memory that is being shared between RAM and a GFX card, or in general how do I contact the BIOS settings? ...

how to automatically start a PC using c

hey guys, is there any way i can automatically turn a pc on without having to go to BIOS? ie from windows using a language or the like ...

More advanced Java Course or C?

Hi guys, I just completed a my first semester in Java and I am trying to decide if I should take a more advanced Java course or take a class in C. Long term I plan to continue to learn them both, however, I am wondering if a deeper understanding of Java will serve me better or if learning the basics of another language will be best. ...

using snprintf to avoid buffer overruns

Hello, gcc 4.4.1 C99 I am using snprintf like this to avoid a buffer overrun. char err_msg[32] = {0}; snprintf(err_msg, sizeof(err_msg) - 1, "[ ST_ENGINE_FAILED ]"); I have added the minus 1 incase the string is over 32 bytes long and I want to include the null terminator. Am I correct in my thinking? Many thanks for any suggestio...

C++ program problem

I am new to C++ programming. So I was trying my luck executing some small programs. I am working on HP-UX which has a compiler whose executable is named aCC. I am trying to execute a small program #include <iostream.h> using namespace std; class myclass { public: int i, j, k; }; int main() { myclass a, b; a.i = 100; ...

How to compare size_t and pid_t with int

What is the right way to use logical operators with size_t and pid_t types? I mean: is legal to write something like the following? e.g.: size_t sz; /* some kind of assignment */ if(sz > 0){ /* do something */ } e.g.: void f(pid_t pid,...){ if(pid > 0){ /* do something */ } /* ... */ } ..or I have to d...

Visual Studio Console App - Prevent window from closing.

This is a probably an embarasing question as no doubt the answer is blindingly obvious. I've used Visual Studio for years, but this is the first time I've done any 'Console Application' development. When I run my application the console window pops up, the program output appears and then the window closes as the application exits. Is ...

Passing Void type parameter in C

Hello there I am working on an assignment in C where I need to pass in an unknown type of parameter into a function. For example suppose I have the following: int changeCount(void* element) { element.Count = element.Count++; return 1; } The reason why variable element is void is because there are 3 types of possibilities. ...

CPU running time of a portion of code

Hi I would like to know the CPU time used by a portion of code.( I am aware of the time command in linux, but that would give me the running time of the complete program, not a portion of it.) Is there any function/command that can help me achieve this. Thanks ...

What are the trade-offs between procedurally copying a file versus using ShellExecute and cp?

There are at least two methods for copying a file in C/C++: procedurally and using ShellExecute. I can post an explanation of each if needed but I'm going to assume that these methods are known. Is there an advantage to using one method over the other? ...

Is chars[4] and 4[chars] the same in C? Why?

I've read this and don't believe it :) I've no compiler here to test. ...

How to catch the ouput from a execl command

I'm using the execl function to run a Linux process from C. When I do, for example: int cmd_quem() { int result; result = fork(); if(result < 0) { exit(-1); } if (result == 0) { execl("/usr/bin/who", "who", NULL); sleep(4); //checking if father is being polite exit(1); } else { // father's time ...

Call another function when main() exits.

Is it possible to call an extra function when main() exits in C? Thanks! ...

Make part of a C lib "private"

Hi all, I'm developing a shared library, and since the code is big, I've decided to split it in many headers and source files, like any normal program :). The problem is that most of these headers are for internal use, i.e. I don't want them to be accessible from outside of my library. So I'm thinking to move them all to a big source ...

Finite State Machine program

I am tasked with creating a small program that can read in the definition of a FSM from input, read some strings from input and determine if those strings are accepted by the FSM based on the definition. I need to write this in either C, C++ or Java. I've scoured the net for ideas on how to get started, but the best I could find was a ...

C sending multiple data types using sendto

In my program I have a few structs and a char array that I want to send as a single entity over UDP. I am struggling to think of a good way to do this. My first thought was to create a structure which contains everything I want to send but it would be of the wrong type for using sendto() How would I store the two structs and a char ar...

Which programming language has very short context-free Grammar in its formal specification?

What programming language has short and beautiful grammars (in EBNF)? Some languages are easer to be parsed. Some time ago I have created a simple VHDL parser, but it was very slow. Not because it is implemented completely in Python, but because VHDL grammar (in EBNF) is huge. The EBNF of Python is beautiful but it is not very short. I...

C Function Skipped at Runtime

I have the following C code in a program: printf("Test before print_foo()"); void print_foo(char board[ROW][COL]); printf("Test after print_foo()"); where print_foo printf's the passed in 2-D character array with proper .c and .h files imported. Console output is only the two printf statements. Debugging, the run-time never even step...