Hey all,
Having some issues with C. I have this is my code:
// First line works, second line does not!
char outbuf[1024];
// char *outbuf = (char *) malloc(1024); // char is always 1
I am passing this outbuf to a method called PK11_CipherOp(), declared in the NSS library. The Documentation for this method can be found here, you ca...
The system() function will launch a new process from C and a Perl script.
What exactly are the differences between processes called by system() in C and from Perl scripts, in terms of representation of error codes?
...
I want to implement a Linux C program to do the following task: it uses FIN scanning to scan all the open ports of a host.
Here's a short description for the FIN scanning(skip if you already know it):Wikipedia: FIN scanning
In FIN scanning, an open port will not respond in any form, while closed port will send back a RST packet. And ev...
I'm in the middle of this C project that I wish to make very memory efficient. In several cases, I am using the void *s of a dynamic array structure I wrote in order to hold bits. I wish to use all 64 (in this case) bits.
I soon realized that you cannot actually do any bit manipulation on a pointer. So my solution was the following:
...
Lets state the conditions where sqlcxt() can cause segmentation fault, I am woking on unix, using ProC for database connections to Oracle database.
My program crashes and the core file shows that the crash is due to the sqlcxt() function
A loadobject was found with an unexpected checksum value.
See `help core mismatch' for details, and...
I'm inventing interview questions that require analysis of C++ code that does something simple with pointers and recursion. I tried to write strcat() in recursive manner:
size_t mystrlen( const char* str )
{
if( *str == 0 ) {
return 0;
}
return 1 + mystrlen( str + 1 );
}
void mystrcpy( char* to, const char* from )
{...
What's going in below isn't an arrayname always a pointer to the first element in C?
int myArray[10] = {0};
printf("%d\n", &myArray); /* prints memadress for first element */
printf("%d\n", myArray); /* this prints a memadress too, shows that the name is a pointer */
printf("%d\n",sizeof(myArray)); /* this prints size of the whole arr...
struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
} BITMAPINFOHEADER
BITMAPINFO bmiCurrWindow;
capGetVideoFormat((*m_pCapWndArray)[i].hCapWnd, &bmiCurrWindow, formatsize...
Hey,
i'm working on a project and i have some problems.I have searched but can not find any satisfied answer.
i have a huge file consists of 0 and 1s.
i'm getting 1024 (my chunk) bits into an array chunk and after that i apply SHA1() function which is implemented in openssl/sha.h library.
char chunk[1024];
while((fgets(chunk,1024...
Using printf to print "\4unix\5lancs\2ac\2uk\0" I find, instead of a print in the form of ♦unix♣lancs☻ac☻uk, I get garbage (♫ ,►E¦§Qh ↕).
I cannot find an explanation for this; I use the following method to tokenise a string:
/**
* Encode the passed string into a string as defined in the RFC.
*/
char * encodeString(char *string) {
...
I am having a function:
int getparam(char *gotstring)
and i am passing the a string argument to it i.e., a string
for eg:
char *sendstring="benjamin"
instead of teh above declaration can i use
int getparam(char gotstring[])
which one is better. and if i have to use int getparam(char gotstring[]) what are all the other changes...
Hi all!
I'm trying to find a function to call a system command (shell command) and get back its result in a C program.
I only found functions like system but these don't return the result of the command.
I just know it in perl : my $results = `my shell command ;
Thanks!
...
How to make an object file to executable file?
...
I am trying to perform a less-than-32bit read over the PCI bus to a VME-bridge chip (Tundra Universe II), which will then go onto the VME bus and picked up by the target.
The target VME application only accepts D32 (a data width read of 32bits) and will ignore anything else.
If I use bit field structure mapped over a VME window (nmap'd...
I am in search of an upgradeable read write lock for win32 with the behaviour of pthreads rwlock, where a read lock can be up- and downgraded.
What I want:
pthread_rwlock_rdlock( &lock );
...read...
if( some condition ) {
pthread_rwlock_wrlock( &lock );
...write...
pthread_rwlock_unlock( &lock );
}
...read...
pthread_rwlock...
I am in the process of porting an application from x86 to x64. I am using Visual Studio 2009; most of the code is C++ and some portions are plain C. The __asm keyword is not supported when compiling towards x64 and our application contains a few portions of inline assembler. I did not write this code so I don't know exactly what et is su...
Hi all.. i was looking for macro which can expand like the following:
FILL_BUFF(4) should be expanded as (0xFF, 0xFF, 0xFF, 0xFF)... what can be the macro written for the above expansion..
...
The problem is to derive a formula for determining number of digits a given decimal number could have in a given base.
For example: The decimal number 100006 can be represented by 17,11,9,8,7,6,8 digits in bases 2,3,4,5,6,7,8 respectively.
Well the formula I derived so far is like this : (log10(num) /log10(base)) + 1.
in C/C++ I use...
I'm developing on Ubuntu 9.10
I'm writing a C program, during my tests & debugs I'm calling malloc and always remember to call free() - This is obviously just during debug.
I'm curious: Am I eating up the free memory the system has which each debugging session? Or does the kernel cleans up the process memory after I shutdown my applica...
I want the function getCategory() to return "invalid" , instead of printing the word "invalid" (i.e instead of using printf ) when input to the function is invalid (i.e.when either height or weight are lower then zero).
please help:
#include<stdio.h>
#include<conio.h>
char getCategory(float height,float weight)
{
char invalid = '\...