I'm trying to parse the string below in a good way so I can get the sub-string stringI-wantToGet:
const char *str = "Hello \"FOO stringI-wantToGet BAR some other extra text";
str will vary in length but always same pattern - FOO and BAR
What I had in mind was something like:
const char *str = "Hello \"FOO stringI-wantToGet BAR some ...
I want to use 'cat myclip.avi' command to send the output to three running thread, i am trying to process same clip file to produce three different result.
can i use dup2 or how i can make pipe with thread not fork?
Sorry about the question being so vague. Maybe I need to reinforce my understanding of dup2.
actually i am using external ...
Hi,
Is there an efficient way to get the least non-negative residue modulo n, where n is positive, in C?
This is quite easy if the number is non-negative, then it's just a % n (where a is the non-negative integer).
However when a is negative, it appears the behaviour, in C89, is implementation defined (thanks kennyTM). I.e. -2 % 11 = ...
having troubles with the following line
HR(md3dDevice->CreateBuffer(&vbd, &vinitData, &mVB));
it appears the CreateBuffer method is having troubles reading &mVB. mVB is defined in box.h and looks like this
ID3D10Buffer* mVB;
Below is the code it its entirety. this is all files that mVB is in.
//Box.cpp
#include "Box.h"
#include "V...
http://en.wikipedia.org/wiki/Binary_search_algorithm#Average_performance
BinarySearch(int A[], int value, int low, int high)
{
int mid;
if (high < low)
return -1;
mid = (low + high) / 2;
if (A[mid] > value)
return BinarySearch(A, value, low, mid-1);
else if (A[mid] < value)
return BinarySearch...
I am creating a 3d plane that lies on the x and z axis, and has hills that extend on the y axis. The bulk of the code looks like this:
float PeaksAndValleys::getHeight(float x, float z)const
{
return 0.3f*( z*sinf(0.1f*x) + x*cosf(0.1f*z) );
}
void PeaksAndValleys::init(ID3D10Device* device, DWORD m, DWORD n, float dx)
{
md3dD...
How can I calculate the time complexity of a recursive algorithm?
int pow1(int x,int n) {
if(n==0){
return 1;
}
else{
return x * pow1(x, n-1);
}
}
int pow2(int x,int n) {
if(n==0){
return 1;
}
else if(n&1){
int p = pow2(x, (n-1)/2)
return x * p * p;
}
else {
...
Hi,
The write function does not print a floating point number in the following code:
#include <unistd.h>
int main(){
float f = 4.5;
write(1,&f,sizeof float);
return 0;
}
This results in:
�@
Whereas:
int main(){
char *c = "Hello world";
write (1,c,strlen(c)+1);
return 0;
}
Prints Hello world as exp...
Im new in programming c with arrays and files.
Im just trying to run the following code but i get warnings like that:
23 44 warning: assignment makes pointer from
integer without a cast
53 error: expected expression before
‘char’
Any help? It might be silly... but I cant find what's wrong.
#include <stdio.h>
FILE ...
I'm trying to execute MS-DOS DEL commands inside a Win32 C program, and I already know that system and popen can be used for this. However, the problem is that both require string literals (type const char) for the commands, and I need something like the DOS equivalent of this Perl code (more or less, don't know if it actually works):
m...
Possible Duplicate:
Average performance of binary search algorithm?
http://en.wikipedia.org/wiki/Binary_search_algorithm#Average_performance
BinarySearch(int A[], int value, int low, int high)
{
int mid;
if (high < low)
return -1;
mid = (low + high) / 2;
if (A[mid] > value)
return BinarySearch(...
I had to compile a small little C program using the following;
gcc sine.c -o sine -lm
I needed the "-lm" because the program included the math.h.
In looking this up under compiler commands man shows it a either -llibrary or -l library.
I could not find any information on what other libraries. Apparently -lm is needed for math.h
what...
hello
Is there library/header already written to manage C++ objects from C using opaque pointers/handles?
I can write one myself, but I would rather use already made solution, especially if it has fortran bindings.
my specific requirements are:
wrapper generation facility (my thought is to use boost preprocessor)
handling objects th...
The Code that follows segfaults on the call to strncpy and I can't see what I am doing wrong. I need another set of eyes to look it this. Essentially I am trying to alloc memory for a struct that is pointed to by an element in a array of pointers to struct.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_POLICY_N...
Is there an easy way (like a free program) that can covert c/c++ code to x86 assembly?
I know that any c compiler does something very similar and that I can just compile the c code and then disassemble the complied executable, but that's kind of an overkill, all I want is to convert a few lines of code.
Does anyone know of some program...
Is there a character sequence recognized as a newline that's defined by the C standard and/or recognized by GCC? How can newlines be simulated after preprocessor directives to have them and C code share the same line? How about using digraphs or trigraphs?
#include <stdlib.h> [NEWLINE] int main() { exit(EXIT_SUCCESS); }
http://en.wiki...
Related question: http://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-c-c
In C code, should integer overflow be addressed whenever integers are added? It seems like pointers and array indexes should be checked at all. When should integer overflow be checked for?
When numbers are added in C without type expl...
I need to extract the SAME type of information (e.g. First name, Last Name, Telephone, ...), from numerous different text sources (each with a different format & different order of the variables of interest).
I want a function that does the extraction based on a regular expression and returns the result as DESCRIPTIVE variables. In ot...
Today I've encountered a very good book : UNIX to Linux® Porting: A Comprehensive Reference
By Alfredo Mendoza, Chakarat Skawratananond, Artis Walker
This reminded me of the thing I always wanted to know. "Porting Linux apps to Windows". I mean porting native Linux apps to native Windows with no platforms involved.
If I can find an...
Hi,
I'm trying to implement the Solovoy-Strassen primality test for arbritrary large integers. I will also be writing a bignum (cannot use 3rd party implementation as this is an academic project). I have decided on the following structure for the bignum:
struct {
uint64_t *tab;
int size; // number of limbs
int sign;
}
I will be...