The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
checking for non-zero value philplasma UNIX for Dummies Questions & Answers 6 01-08-2008 04:51 PM
checking uid filthymonk Shell Programming and Scripting 7 07-19-2007 10:40 PM
Checking cp progress MarGur UNIX for Dummies Questions & Answers 0 05-15-2007 04:13 PM
Checking for PXE maestro@altiris SUN Solaris 5 05-25-2004 12:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 03-10-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,861
You need to do something like the following

Code:
read(fd, &mydata, (size_t)mydata )
  #9 (permalink)  
Old 03-10-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Quote:
Originally Posted by ramkrix View Post
Thanks fmurphy for your reply.

if I have a structure defined at the beginning in another prgm instaed of an char array name[20],can I use like this?

struct bio {
char name[20];
int age;
float salary;
}

main()
{
struct bio mydata;
--------
--------
--------

read(fd, &mydata, (size_t) ))

}
How can we use the size_t with structure?

Thanks in Advance..

Ramkrix
fpmurphy's post clearly says that size_t is a typedef for an unsigned long. Declare a variable of that type as a structure member before using it in the read() call. The (size_t) is the C lang notation for a typecast used when converting from one type to another. Wrap code tags around your program listings.

Code:
struct bio
{
     char name[20];
     int age;
     float salary;
     size_t num_of_bytes_read;
}

main()
{
    read(fd, &mydata, num_of_bytes_read)
}
  #10 (permalink)  
Old 03-11-2008
ramkrix ramkrix is offline
Registered User
  
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 52
Thanks fmurphy for your kind xplanation.

Regards,
Ramkrix
  #11 (permalink)  
Old 03-11-2008
ramkrix ramkrix is offline
Registered User
  
 

Join Date: Dec 2007
Location: TamilNadu,INDIA
Posts: 52
Thank you Shamrock

Regards,
Ramkrix
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0