thelamb 163 Posting Pro in Training

'ticket' is an integer, but you expect your user to input 'A', 'B' etc.
What could go wrong?

You should check if the cin >> ticket is even succeeding, before trying to use 'ticket' in the switch case.

thelamb 163 Posting Pro in Training

C strings are 0 terminated, you are correctly creating the chars with size 81, and copying only 80 bytes to them, but what is the value of the last char? Exactly... it is garbage data.

So, you must initialize the char array to zero, you can do this in several ways:

char test[20] = { '\0' };
char test1[20];
test1[19] = '\0';
char test2[20];
memset( test2, 0x0, 20 );

I think this also answers your second question about str[0] = '\0'; ;), if not feel free to ask more detailed questions.

thelamb 163 Posting Pro in Training

Your cin >> in; (request the user for input) is outside the do...while loop.
So you ask input once and then it's continuously 'executing' the switch case with the same 'in' value.

thelamb 163 Posting Pro in Training

Exceptions do not exist in C, so including the stdlib won't do any good.
I don't know the exact details, but maybe Visual C++ accepts 'catch' without any specification as to what you want to catch, and g++ doesn't.

In any case, I suggest you specify what exceptions you want to catch, for example:

try {
   throw 1;
} catch( int e )
{ 

}

try {
    throw std::something;
} catch( std::exception& e )
{

}

try {

} catch( ... )  // Catches every C++ exception
{

}
thelamb 163 Posting Pro in Training

Your use of brackets indicates that you don't fully understand the do...while.
You're writing your code like:

do {
 ...something
} while( light == false );
{
 ...do something else
}

There are no statements in the do...while that will ever change the light boolean, and the part after the while( ... ); will only get executed once you break out of the do...while, which is never.

So you're probably looking to do something like:

cout << "you're in a dark room etc."
do {
    cout << "What would you like to do?\n";
    cin >> options;
    if( options == ... || options == ... ) {
        light = true;
        cout << "And there was light!\n";
    } else 
        cout << "The room stays as dark as it were\n";
    }
} while( light == false );

// Here, a correct option was given
thelamb 163 Posting Pro in Training

I just write:

if( 2 == a )
    return true;

return false;
thelamb 163 Posting Pro in Training

CreateThread doesn't take a pointer to a class's method, let's read the error message together:
Your argument type: 'DWORD (PMessenger:: )(void*)'
Expected arg type: 'DWORD (*)(void*)'

So CreateThread is expecting a pointer to a function that returns a DWORD and takes void* as argument. There are several ways to 'beat' this problem, because you cannot simply cast your function to a DWORD (*)(void*).

You can use a 3rd party library like 'boost', which allows you to use pointers to member functions to start a thread.
You can create a small 'wrapper' function like this:

DWORD start_ServerMsgThread( LPVOID param )
{
   PMessenger* pMsg = static_cast<PMessenger*>( param );
   pMsg->ServerMsgThread();
}

And start the thread like:

CreateThread( NULL, 0, &start_ServerMsgThread, static_cast<LPVOID>(this), 0, 0);

You hand over the SOCKET to ServerMsgThread, but you can just store this as a private member variable and access it from ServerMsgThread.
If you don't want to do this, you can create a structure with 2 members:

struct StartThreadStruct {
  SOCKET s;
  PMessenger* pMsg;
};

Allocate this, hand it over to CreateThread and from start_ServerMsgThread pass it to ServerMsgThread and access the SOCKET from there.

I hope that helps.

thelamb 163 Posting Pro in Training

Not necessarily, everything you are assuming here depends on implementation details of the library.
It is unsafe, and bad practice to do this.

Why not check every function (provided that it returns something that indicates an error of course)?

You can still use the try/catch block to make life a little easier:

try {
    if( ! sftp->Connect(hostname, port) )
        throw std::exception( "Connect failed." );

} catch( std::exception& except )
{
    cout << "Exception! Message: " << except.what() << "\n";
}

*edit: cout is ofcourse only as an example.. if you don't have a console application this won't work out of course*

Then you should look at the libraries documentation if they provide any error-code that will give you more details about _what_ exactly went wrong.

thelamb 163 Posting Pro in Training

Are you sure this 'Chilkat' FTP library throws exceptions when something goes wrong? Maybe it is expecting you to check the return value of WriteFile etc.

thelamb 163 Posting Pro in Training

Your console application has some functions, that are probably called from the main() function.

This 'logic' you need to put in the GUI application, but instead of calling the functions from winmain you can call them for example when the user clicks a button on your GUI, and you pass as a parameter any configuration that the user did in your GUI.

I can't tell you what changes you have to make, because I dont know how you coded your Console app... but some obvious things like 'cout' won't work in the GUI app.

thelamb 163 Posting Pro in Training

Why would you want to keep the console application seperate? There aren't (m)any real world applications that spawn a new process to do some work and only use the GUI for configuration.

So just create one GUI project, and put the code from the console application in there... You will probably have to make some modifications but I would go that way.

If you decide to use CreateProcess anyway you don't need to store the configuration in a file, you can pass it as a command line parameter.
Just like you can create a process through cmd like:
>myProgram.exe argument1 argument2

thelamb 163 Posting Pro in Training

Probably because you didn't specify the namespace. nth_element is an std function so is only defined in the std namespace.

U have some options:
- Use std::nth_element
- Put using std::nth_element; after including the header file
- Put using namespace std; after including the header file (not a very sexy solution).

thelamb 163 Posting Pro in Training

Ok first of all: Why are you passing this list as pointer and not a const&? You are not modifying the passed list in any way...
If you insist on using a pointer to pass it, we need to see how you're calling this function to be able to see what's wrong.

thelamb 163 Posting Pro in Training

Well I can imagine that, I work closely together with a VB.net programmer and in the beginning she had more trouble understanding my code than I had understanding hers.

However, now she can follow most of what I write eventhough she hasn't written a line of C in years.

So I think the answer is that C++ is generally more difficult and will take more time to grasp... but when you do you have something powerful at the tip of your fingers ;).

(One thing that C++ does a lot is leaving the programmer to decide how to approach a problem... the same goal can be achieved in many many ways which to me was also very confusing when I started).

thelamb 163 Posting Pro in Training

What your teacher said is true to some extent, a lot of programming techniques are applicable to multiple languages. This does not mean that every language is equally easy to learn. C and C++ are lower languages than languages like VB, java etc. generally this also means that are harder to understand. Compare it to Assembly language, which is the lowest 'humanly readable' language.. and it's much harder to understand than C/C++.

Also, you say VB seems easy to you... but getting a program to work does not mean it's correct, you may have used bad or ineffecient techniques or only aimed at small problems: there are aspects of VB that are difficult to grasp as well.

So don't give up on C++ just because it seems so different/difficult at start... if you really love programming you will get through it and appreciate the power of C++ ;).

thelamb 163 Posting Pro in Training

I assume you are re-opening the same file because you first want to create it and then edit the existing file. There would be no problem if you don't re-open the file and just to seekp and put(c).

What you want is of course possible with fstream, it would be horrible to have to revert to C-code just for this.

Here is how you do it:

out.write((char *) &h, sizeof h );
out.close();

out.open("file2", ios::in |ios::out |ios::binary); // <-- also open with ios::in
out.seekp(5,ios::beg);
c='z';
out.put(c);
out.close();

It's a subtle difference... but if you don't include ios::in the original content is truncated when overwriting existing data (not if you are appending.. then ios::in is not needed).

thelamb 163 Posting Pro in Training

Well, allocating sort of a 'pointer pool' will be more efficient if you will be doing a lot of allocation/deallocations. But if you use a vector this can be done more easily. E.g. at startup you can say 'vInstances.resize( some_number )' and it will pre-allocate memory of this size. If the vector then grows past this size the vector will internally allocate more memory.

So, in essence.. this pre-allocated array you have exposes a lot of implementation detail (the Existance-array) that you really don't want to be dealing with. So definitely have a look at vectors, and at resize.

This 'problem' is simmilar to an assigment that we let students of the OperatingSystems at my univeristy do. They are provided with a structure, and a benchmark program which allocates and deallocated thousands of instances. They need to code a 'manager' to speed this up.
What they mostly do is write a wrapper for malloc(), the first time it is called they allocate 100 * size_of_structure, and whenever a request is made for a new allocation, they increase an index and just return a pointer somewhere in this pre-allocated pool.

Performance of 100000 times 100 allocation/deallocations on my machine was 0.11 second with the new malloc versus 0.5 without any pre-allocation.
So this is not a difference that you are likely to notice.

thelamb 163 Posting Pro in Training

Hmm, your method to search for the next 'available' pointer-'spot' is not very efficient.
You are using C-style arrays... which is no necessarily wrong but what you're trying to do is much easier by using C++ vector's. You won't need the 'instanceExists' array then:

#include <vector>
using std::vector;

vector<baseObject*> vInstances;

createInstance()
{
   baseObject* pBase = new something();
   vInstances.push_back( pBase );
}

vectors are maybe slightly slower than bare C arrays, but you need to be very confident with working with arrays to beat the vector's performance (e.g. writing correct search algorithms etc.).

What don't you understand about virtual functions? You use them (almost) correctly. One of the purposes is if you have multiple types of object, which all share a common functionality, so they inherit from one base class. But there can be some functionality that is implemented differently for the different types of objects.
Consider shapes(circle, rectangle etc.) they all have dimensions, and they all have an area... but the area of a circle is calculated differently than the are of a rectangle. So the base class defines a virtual area functions, and all shapes implement this in their own specific way.
Also, if you call virtual functions through a pointer or a reference of the base class the compiler will know that it has to call the virtual function of the derived class.

What can be improved in your example:

class baseObject
{
    public:
    virtual void Step() = 0;
};

the …

thelamb 163 Posting Pro in Training

You can place the entire (nameless)struct's declaration in the class header.

e.g.:

class myWrapper
{
    struct 
    {
        int houseNumber;
    } address;

    public:
        myWrapper() { address.houseNumber = 555; } // this is valid
};

int main
{
    No way to access address from here, apart from a public interface.
}
thelamb 163 Posting Pro in Training

So it does not say that it cannot find libboost_regex.so?
In that case: does /usr/lib contain any other boost libraries?

If I remember right.. (I've used this library a while ago) the regex lib depends on some other boost libraries that you need to link to aswell. Maybe post the errors your getting for a better understanding of the problem.

thelamb 163 Posting Pro in Training

I've had the same 'problem' as you when I started (I'm also selftaught)... but I don't really understand what error handling has to do with it... but let me comment on that first:

You created your own macro that in debug-mode prints some information about the error.. this is a fine idea, you could also use assertations (lookup ASSERT). But in many cases, you also want to have some error-reporting in a release build.

I mostly use an exception class for this (CExcept), which inherits from std::exception. I overload operator<< in this class.
I can then do error checking:

void myFunction()
{
    if( hasError() )
        throw CExcept( SOME_EXCEPTION_ENUM ) << "myFunction failed horribly";
}

int main()
{
   try {

   } catch( CExcept& except )  // or std::exception& 
   {
        if( HORRIBLE_EXCEPTION_CODE == except.getCode() )
            err_out << except << "\n"; // in Debug build, this won't do anything
   }
}

err_out either functions as cout, or some file stream object or it could even be a class which emits the message as messagebox etc...
And it implements a << for ( err_out, except ) of course.

This way, if I want to change something as to how errors are handled in general I can do it in one place (Want errors to output to file? Just change err_out).
Also... a lot of functions set some error code (GetLastError in Windows or errno in Linux) with a simple #ifdef _WIN32 or #ifdef __linux__ in the overloaded …

thelamb 163 Posting Pro in Training

There are left over characters in the buffer after the first cin.getline(), the second cin.getline() is picking this up.

Read this:
http://www.daniweb.com/forums/thread90228.html

thelamb 163 Posting Pro in Training

Any decent compiler should have the short circuit evaluation (it still blows my mind why a compiler would do otherwise).

So if you think about your own change/question ... what do you think will happen?

thelamb 163 Posting Pro in Training

Just for the fun of it, what does the OP(or someone else) think the ouput of this snippet will be:

#include <iostream>
using std::cout;

bool returnTrue ( ) { cout << "ret TRUE\n"; return true; }
bool returnFalse( ) { cout << "ret FALSE\n"; return false; }

int main()
{
    if( returnTrue() || returnFalse() )
        cout << "toot\n";
}

Note to devs:

Maybe it's an idea to add some 'SPOILER' tag? So with questions like these I could put the answer in SPOILER tags, so anyone who wants to think about it for him/herself before seeing the answer can chose so. (Ok Ok the real reason is that I won't look bad if I forget about this thread and someone continues on the question)

thelamb 163 Posting Pro in Training

Yes, that makes absolute sense.

So what do we make of the OP's problem... compiler not following the standard?

Edit:
Maybe the OP should try to compile his code in 'release' mode.. with all optimizations enabled. If it still attempts to evaluate the v[2]... I would chose a different compiler ;)

thelamb 163 Posting Pro in Training

I guess you mean "if the first evaluates to false" instead?

Oeps, fixed.

On compile time it has no idea if v[2] is going to be valid or not, so if anyone has a reason why a compiler would decide to emit code that evaluates this second expression... please share.

thelamb 163 Posting Pro in Training

If I remember the C++ programming language book correctly the standard states that the second expression should not be evaluated if the first evaluates to false(would be pointless)... but maybe the OP's compiler doesn't follow this standard strictly.. or I am remembering wrong and it's not actually in the standard.

In any case, consider this (maybe the OP should try this code):

#include <iostream>
using std::cout;

bool returnTrue ( ) { cout << "ret TRUE\n"; return true; }
bool returnFalse( ) { cout << "ret FALSE\n"; return false; }

int main()
{
    if( returnTrue() && returnFalse() )
        cout << "toot\n";

    if( returnFalse() && returnTrue() )
        cout << "toot\n";
}

OUTPUT (for me):

ret TRUE
ret FALSE
ret FALSE

So in the second case, the returnTrue is not evaluated.

I'm not really sure why, or even how the OP's compiler emits this as ASM... if I were to look at the ASM code of what I just posted, it would call returnTrue and compare it to true, if the comparison fails there would be a JMP over the entire If-block, skipping the second comparison.
It doesn't make sense to me why the compiler would decide to evaluate both and then compare both...

thelamb 163 Posting Pro in Training

Let me get this straight.. the code you are currently posting (with the temp stringstream) is working, but if you write

arq_linha_part >> parm;

It gives you an error?
If so, then it should give you an error. The short answer is that std::string (the arq_linha_part variable) does not have a >> operator that takes double (the parm) as second argument.

So one of the ways to convert an std::string to a double is by using an std::stringstream like you have in the current code.

Also.. in future it is probably not necessary to paste all of the compiler errors, after the first error the compiler usually gets totally confused and will spit out many more errors that might not be errors anymore after you fix the first few errors.

thelamb 163 Posting Pro in Training

yay :D

Now get rid of that 'system("pause")' call... check the sticky's on this board for information about how to 'properly' pause the execution of your program.

thelamb 163 Posting Pro in Training

No... you're still doing _exactly_ what I said you should 'never ever' do...

I really don't know how I can make it more clear other than writing the code for you, which defeats the point of you learning how to do it.

Do you know that this is possible:

int xValue = 5;
int yValue = 6;

node* newNode = new node();
newNode->infoX = xValue;
newNode->infoY = yValue;

delete newNode; // Don't forget to free the memory once you are done with it!!
thelamb 163 Posting Pro in Training

" I tried the idea of creating two newNodes and storing the y data in it. "

That's not what I meant... you were already creating two newNodes in your original solution, and I tried to make you think about _why_ you do that.

Just think logically, you have one structure that has a place to store infoX and infoY _together_. So when you ask the user to input X and Y, why do you want to store this in 2 different structures instatiations?

What I just realized is that in your original solution you defined one newNode pointer, and just called newNode = new node() twice... And now you changed it to newNodeX and newNodeY, I missed that in my first post, I thought you already had a newNodeX and newNodeY.


In any case, I think you don't understand the use of the 'new' operator.

int* pInt;   // pointer to an int variable
int* pInt2;  // Idem.

// Both pInt and pInt2 are 'lose' pointers, they are totally useless at the  moment.
// So let's make them useful:
pInt  = new int;
pInt2 = new int[2];
// Now the new operator has allocated memory where pInt and pInt2 will be stored.
*pInt = 5;   // 'value-pointed-by' pInt is now set to 5
pInt2[0] = 10; 
pInt2[1] = 15; 

// Because we've dynamically created the storage for pInt and pInt2, we also need to free it:
delete pInt;
delete[] pInt2; // pInt2 is …
thelamb 163 Posting Pro in Training

It really makes sense what you're doing wrong... I think you basically wrote the code that sents newNode->x and then copy/pasted it, changing 'x' to 'y'.

Look at the things that you are doing for _both_ x and y, and think about if it makes sense...

Let me state it a little differently:
You do:
-> Ask user for X
-> Create newNode
-> Initialize newNode->x
-> Ask user for Y
-> Create newNode
-> Initialize newNode->y

What if you would do this:
-> Ask user for X
-> Ask user for Y
How would you continue this? Create two newNode's or one?

thelamb 163 Posting Pro in Training

As far as I can see, you are never calling calcArea().

thelamb 163 Posting Pro in Training

Ok, so show us how you're reading the file and how(where) you're resetting the file pointer

thelamb 163 Posting Pro in Training

Define "Doesn't really work" .. what are your results? What do you expect?

thelamb 163 Posting Pro in Training

Are you calling your destructor function explicitly? If so.. you probably shouldn't ;)

thelamb 163 Posting Pro in Training

Yes, I find the use of C functions like sprintf dirty in C++ code. I guess I should've mentioned that this is somewhat a personal preference and not a strict rule though ;).

So I guess now the OP has all the information to chose between tedious(yes, it is a better description) or (in my eyes) cleaner solution ^^.

thelamb 163 Posting Pro in Training

stringstreams are a much cleaner solution than dirty C sprintf functions and should definitely be preferred when writing C++ code

thelamb 163 Posting Pro in Training

There is a lot of information available on the internet that explain virtual functions and all the others things you mention much better than I would be able to explain in a post here.

But what I said before is still true to start with.. ask yourself the questions I mentioned, especially about which classes have information in common.

If you think that some of the classes have something in common, you can put this information in a 'base class' and let all the other classes that need this information inherit from the base class.

Take for example a car and a bus. They both have wheels, the both have an engine etc.
So you could create a base class 'vehicle' that contains information about wheels and engines and let the car and bus classes inherit from vehicle:

class vehicle
{
   int m_NumBerOfWheels;
   int m_HorsePower;
};

class car : public vehicle
{
   car() { // we can use m_HorsePower etc. here }
};

I ommitted the constructor/destructor and public/private modifiers but u get the idea...
Now every vehicle needs a way to start, but let's assume that a car and a bus start in a different way, this is where you could use virtual functions:

class vehicle
{
   virtual bool start()  // Default start() function
   {
       cout << "vehicle starting\n";
   }
   virtual bool stop() = 0; // PURE virtual function, means every class that inherits from vehicle MUST implement it
};

class car …
thelamb 163 Posting Pro in Training
#include<iostream.h>
void hi(void)
void name(void)
int main()
{

First of all, you should include <iostream>, not <iostream.h>
Secondly, you should tell us in what line the error is.. or at least copy/paste the exact error.
But I tried to compile your code and the error is in the 3 lines that I pasted above: Now if you look at just those lines, what do you think is missing?

thelamb 163 Posting Pro in Training

No one is going to design this for you since you don't show us that you have made any effort at all to think about the problem (other than how to write your question and copy/paste the problem description).

You know that you want to use OOP concepts to write this game... so start thinking: What kind of objects do you have in this game? Do any of the object have anything in common? Which objects interact with eachother? By asking yourself those kind of questions you can decide about a design.

So start thinking and ask _specific_ questions here if there is something that you do not understand, or you would like to discuss a design approach that you made.

thelamb 163 Posting Pro in Training

Your do..while statemen is wrong (so you are getting the error at line 15 I guess, not at 9 where you are also using cin). This indicates that cin itself isn't the problem, but something closely before the line where the error is.

A do/while is written like:

do
{
   doSomething();
} while( condition );  //<-- don't forget the ; here
thelamb 163 Posting Pro in Training

His approach isn't C-Style as the int i, ii; is not at the start of a scope block.
He does re-use the 'i' in two for loops, which is asking for confusion.

Anyway Ral78 what they are trying to point out is that it is good practice to make a variable's scope as short as possible (do you know what a 'scope' is?). So it is better to write code like:

for( int i = 0; i < n; ++i )
{
   // we can use i here
}
// here we can _not_ use i anymore

for( int i = 0; i < n; ++i )
{
  // Here we can use the new i again
}
// Nope, can't use i anymore
thelamb 163 Posting Pro in Training

First of all: Do you understand why there is only one beep and after that never again?

Secondly, let's think about your problem. You have an X number of objects(windows) and you want them to perform an action only once. So for each of these objects you can store a 'state' whether they have already performed the action or not.

Knowing this, what parameter/variable is unique for every object? This is a parameter that you can associate with the state variable.

In the end it comes down to storing the unique_object_identifier + state and searching for the unique_object_identifier in the TitleProc, to get the state and based on the state perform the action or not.

vadalaz commented: Thanks! +0
thelamb 163 Posting Pro in Training

A much better (C++) solution would be to move away from C-Style arrays and use a container class like 'vector'.

This will also allow you to use std algorithms like std::sort to sort the vector

thelamb 163 Posting Pro in Training
void main()

Are you sure this is correct? If so.. why?

your enemy variable is a local, automatic variable. This means it will be destructed when it goes out of scope(do you know what a scope is?).

If you wish to delete the variable at some 'random' point in your code you need to ensure that it goes out of scope at this point OR you need to dynamically allocate the object.

Example:

int myFunction()
{  // start of myFunction scope
    int myInt;
    int* myDynamicInt = new int( 5 );
    while( true )
    { // start of while scope
         int mySecondInt;
    } // end of while scope (mySecondInt is destroyed here).

    delete myDynamicInt; // destroy myDynamicInt
}  // end of myFunction scope (myInt is destroyed here)

If you would have forgotten the 'delete myDynamicInt' in my example, it would cause a memory leak (myDynamicInt would never be cleaned up).

I hope that clears things up a little.

thelamb 163 Posting Pro in Training

Look closely at my previous posts, I posted a code snippet there and asked you what you think would happen... you shouldn't just ignore that :P But here we go again:

int main()
{
     float myFloat = 0;
     {
          float myFloat2 = 5;
          myFloat = myFloat + myFloat2;
     }
     cout << "myFloat: " << myFloat << "\n";
     cout << "myFloat2: " << myFloat2 << "\n";
}

And another one to think about:

int main()
{
     float myFloat = 0;
     float myFloat2 = 3;
     {
          float myFloat2 = 5;
          myFloat = myFloat + myFloat2;
     }
     cout << "myFloat: " << myFloat << "\n";
     cout << "myFloat2: " << myFloat2 << "\n";
}

What do you think (without trying to run it) will be the output in the 2 cases?

thelamb 163 Posting Pro in Training

Don't you already do it with 'Equipment' ?

You have several options on how to store the Hero object in the vector, you can store it like you store the "String" in Equipment, or you can decide to store a pointer to a Hero object (Hero*) instead.. it depends on the requirements of the assignment what to chose.

I don't know the lvp library, but with the standard library the vector class has a member function "push_back" which allows you to add elements to the vector. (e.g. vHeroArray.push_back( new Hero() ); if you want to store hero pointers)

thelamb 163 Posting Pro in Training

Ok you need to understand 'locality' of a variable.

Your numberInputs is an argument to the function calculateAverage, correct? This means that when you call the calculateAverate function, you will hand over a value for the numberInputs, this value will then be available for use in the calculateAverage function.

I think it's best I write a small example:

int increase( int myInt )
{
    return myInt + 1;
}

int main()
{
    int myInt = 1;              // int variable that is avaiable to main.
    int mySecondInt;        // another int variable that is available to main.
    mySecondInt = increase( myInt );  // hand over the myInt from main to increase and store the result of the function in mySecondInt

}

Note how I am able to use a variable called 'myInt' in both the increase function and in main, the reason is that they are in completely different 'scopes'.

If you make a variable global however, it will be available to all functions:

int myGlobalInt;
void increaseGlobalInt()
{
    myGlobalInt++;
}

int main()
{
   myGlobalInt = 6;
   increaseGlobalInt();
}

Let's write up another example and see what you think will happen:

int main()
{
   int myFirstInt = 1;
   {
          int mySecondInt = 2;
          myFirstInt = myFirstInt + mySecondInt;
    }

   cout << "First int: " << myFirstInt << "\n";
   cout << "Second int: " << mySecondInt << "\n";
}
thelamb 163 Posting Pro in Training

I didn't look through your whole code, but what you do with the thread makes no sense.

You create the thread, and then wait for it to complete. Why is this needed? E.g. why did you chose to use a thread rather than just call the function directly.

Anyway.. to answer your question:

pthread_create(&thread1, NULL, (void*) cvWriteFrame(writer0, frame0) , NULL);	
pthread_join(thread1, NULL);

pthread_create expects a pointer to a function with prototype:
void *(__cdecl *)(void *)

This means it is a function that returns nothing(void) and takes one void* as argument.
So cvWriteFrame is not going to work directly with pthread_create because it takes 2 arguments, not 1. I guess this function comes from a library so you can't change it to only take one argument.

So... think about if you really need the thread, if you think you do... read up pthreads