LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2009, 01:24 AM   #1
lp_s
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 0
Smile threads doesn't show words in text file


hey every body i'm new and i have questions.

in my os lab course we're working on two threads and the program was about to type numbers and words one thread for numbers and another for words and cuz it doesn't space for showing all of them in terminal we transfered it into a txt fill but in txt file only the numbers where shown and i want to khnow why?

please help me. thank you.
 
Old 04-30-2009, 07:48 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Welcome to LQ!

Not enough information to aid you with your problem. Post a sample of the output data along with what you have attempted to complete the action on the data.

It does sound like homework to me. Read the LQ Rules!
 
Old 05-13-2009, 12:11 AM   #3
lp_s
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Unhappy why threads didn't show words in *.txt files?????????????

hey
i wrote this program:
#include <pthread.h>
#include <stdio.h>

struct char_print_parms
{

char character;

int count;
};


void* char_print (void* parameters)
{
struct char_print_parms* p = (struct char_print_parms*) parameters;
int i;
for (i = 0; i < p->count; ++i)
fputc (p->character, stderr);
return NULL;
}

int main ()
{
//int j;
//for (j = 0; j<200000;j++)
////{
//printf (" %d ",j);
//}
pthread_t thread1_id;
pthread_t thread2_id;
struct char_print_parms thread1_args;
struct char_print_parms thread2_args;

thread1_args.character = '1';
thread1_args.count = 30000;
pthread_create (&thread1_id, NULL, &char_print, &thread1_args);

thread2_args.character = 'a';
thread2_args.count = 20000;
pthread_create (&thread2_id, NULL, &char_print, &thread2_args);

pthread_join (thread1_id, NULL);

pthread_join (thread2_id, NULL);
return 0;
}
then in this program you will have print of number (1)
for 30000 times and word (a) for 20000 times but if you want to have them in text file the word (a) doesn't shown why???????????????????
help me please.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing a text file (switching around words) SentralOrigin Linux - General 2 07-17-2008 03:15 PM
Replacing words in a text file Raghavan_sat Programming 3 05-27-2008 03:11 PM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM
How do I show the structur of directory with words? pelgrim Linux - Newbie 4 03-17-2003 06:30 PM
How can I catch some "KEY WORDS" from a text file without opening it? yuzuohong Linux - General 1 06-14-2002 09:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration