hello,

i am a beginner to visual studio. i want to know how can i use pthread in visual studio 2008. am i supposed to download the dll? if yes, then after downloading how can i use that dll in my project.

please help.

Karishma.

i am try to use pthread on c++ visual studio 2008 too , its not working with me the code is written on pthread unix and it works 100% i need to run it on windows What should i do ???????

#include <iostream>

int main()
{
   while(true)
   {
      std::cout << "Read previous post\n";
   }
}

Thank you for your reply, I downloaded the heade filt from that link, the thing is I could not add the pthread to visual studio, I dont have much experiance with it could you please tell me how to do it .

this simple code I need to start with

#include <pthread.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string.h>

using namespace std;
FILE *fpa;
FILE *fpw;
void *print(void * arg)
{
    char c[500];
    FILE *p=(FILE *) arg;
    //cout<<p<<"<<<<<<<<<<<<<<<<<";
    rewind (p);
    while (fgets(c,500, p))
    {
        cout<<c<<endl;
    }


}
int main ()
{
    pthread_t printt;
    pthread_t printt1;
    void * exit_status;
    char infile1[30];
    char infile2[30];
    int k;
    string text;
    char text2[500];
    cout<<"\ninsert K:";
    cin>>k;
    cout<<"\ninsert first file:";
    cin>>infile1;
    cout<<"\ninsert second file:";
    cin>>infile2;

    FILE *fp= fopen(infile1,"rw");  
    FILE *fp2= fopen(infile2,"rw"); 
    fpa= fopen("A.txt","w+");   
    fpw= fopen("W.txt","w+");   
    while (fgets(text2, 500,fp))
    {
        if (strlen(text2)<k)
        {   
            fputs(text2, fpa);
        }
        else
        {
            fputs(text2, fpw);
        }
    }
    pthread_create(&printt,NULL,print,fpa);
    pthread_create(&printt1,NULL,print,fpw);

    pthread_join(printt, &exit_status);
    pthread_join(printt1, &exit_status);

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.