I've redirected stdout of a child process spawned with CreateProcess to a pipe. It works fine except that, as far as I can tell, no information about color changes are coming through. The child process is using SetConsoleTextAttribute to change the text color--is it possible to detect this through the pipe and, if so, how?
I'm ultimat...
Hi,
Is there a way to replace any keyword in a text file using POSIX calls, without re creating the file..
If yes Please tell me how to do it..
Thanks in advance..
...
Is the following conversion safe?
int b[10][10];
char *x;
int a[]={0,1,2,3,4,5,6,7,8,9};
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
b[i][j]=a[i];
for(x=(char *)&b[0];x<=(char *)&b[9][9];x+=sizeof(a+1)) // Problem lies here!
printf("%d\n",*x);
I don't think the above conversion in the for loop is safe (I think it is platfo...
What can be done to know and list all running processes on a remote computer?
One idea is to have a server listening to our request on the remote machine and the other one is to use ssh.
The problem is i dont know whether there will be such a server running on the remote machine and i cannot use ssh because it needs authentication.
Is th...
I’m trying to figure out a way to use nested global structs as a sort of API namespacing for my C library.
Specifically, I want to expose a single Primary ‘namespacing struct,’ that contains other such structs (such as Primary.Secondary), that themselves contain function pointers (Primary.Secondary.a_function()).
I’ve abstracted out th...
I declared an enum in my implementation file as shown below, and declared a variable of that type in my interface as PlayerState thePlayerState; and used the variable in my methods. But I am getting errors stating that it is undeclared. How do I correctly declare and use a variable of type PlayerState in my methods?:
In the .m file
@im...
Hello, I posted this on daniweb, but have revised my thoughts on the matter.
Basically my 'Integrated Software Systems' class midterm is to take some code (either you wrote or someone else's) and optimize it.
I thought to myself why not use this opportunity to enrich the open source community, I know it's really going to only be a fu...
What is the most efficient way to create a floating point mode where the user can enter 'f' or 'i' to switch between integer and floating point? I'd like to do this without having to copy the entire code for floats. I know typecasting is an option but I'm not completely sure if it's the safest way.
#include <stdio.h>
#include <stdlib.h>...
I came across this code for the binary representation of a number. I want to know the need for using !! in the code.
int main() {
int n,i;
unsigned flag = 1<<(sizeof(int) * 8 - 1);
printf("Input the number\n");
scanf("%d",&n);
for(i=0;i<sizeof(int)*8;i++) {
printf("%d",!!(n & flag) );
...
Besides __ LINE__ and __ FILE__
are there other useful pre-defined macros, like
__ FUNCTION_NAME__
?
If not, but you know of other cool/useful defined macros (especially for debugging purposes), I'd love to hear about them.
EDIT: some have asked about platform:
I'm using gcc/g++ on MacOSX.
...
In a kernel level project I want to encrypt a packet using des algorithm , need to use the function
static int des_setkey(void *ctx,const u8 *key,
unsigned int keylen,
u32 *flags)
I want to know how the key to be passed to the function , which value to be used as the to the key , its...
Hi!
I have problems with this program. The idea is to read strings from text file and include them in 2D dynamic array with constant number of columns and varying number of rows. If the initial number of rows is not enough to include all strings the memory block for the array has to be reallocated. The code is compiling OK but the execut...
We recently received a report that our application will occasionally fail to run. I tracked down the problem code to this:
struct ARRAY2D
{
long[] col;
}
int numRows = 800000;
int numCols = 300;
array = (ARRAY2D*) malloc(numRows * numCols * sizeof(long))
This allocation of 800 Mb can fail if the user doesn't have a large enough fr...
I have seen countless references about endianness and what it means. I got no problems about that...
However, my coding project is a simple game to run on linux and windows, on standard "gamer" hardware.
Do I need to worry about endianness in this case? When should I need to worry about it?
My code is simple C and SDL+GL, the only compl...
Let's say I have the following C code:
int main () {
int *p = malloc(10 * sizeof *p);
*p = 42;
return 0; //Exiting without freeing the allocated memory
}
When I compile and execute that C program, ie after allocating some space in memory, will that memory I allocated be still allocated (ie basically taking up space) after I exi...
I have experienced some strange behavior of Objective-C++.
I have an Objective-C++ class, and it calls a classic C function in a method body.
But linker cannot find the C function.
I described the problem here:
http://stackoverflow.com/questions/2213589/xcode-print-symbol-not-found-for-my-c-function-which-used-in-objective-c-method-b/22...
I have a simple C program which has a pointer to a character array. To initiate it, I use malloc, and resize then set it x number of times later on in the program.
When I resize it once with realloc, gdb doesn't show any errors, however, if I try calling the resize function again, gdb shows the following error:
warning: Invalid Address...
Howdy. I am in a networking class and we are creating our own "networking API" using the socket functions we have learned in class thus far.
For the assignment the professor provided the already complete chat and server programs and we were to fill in a blank .c file that had an associated header file that described the function calls i...
I am following this tutorial (http://theocacao.com/document.page/234). I am confused about this paragraph, mainly the lines relating to calloc:
We can also use a variation of the malloc function, called calloc. The calloc function takes two arguments, a value count and the base value size. It also clears the memory before returning a...
I'm trying to calculate the sum based off of sets of numbers received from the command line and I use a companion program called worker to due the computation for me. If the amount of numbers received is odd, it will add a zero to the amount of numbers to make the set even.
This is the flow of the program in an understandable way(credit...