The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #9 (permalink)  
Old 03-10-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
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)
}