Sponsored Content
Top Forums Programming help with struct command in C Post 302496147 by jim mcnamara on Saturday 12th of February 2011 12:27:40 PM
Old 02-12-2011
stat returns -1 on error.

Code:
  if(stat(what, &my) == -1)
  { 
     perror("Cannot stat file");
     exit(1);
  }

OR before doing anything with a file call access() which is specifically meant to check permissions + access to file
 

10 More Discussions You Might Find Interesting

1. Programming

Struct Initialization

Hi We are using a code generator for initializing structures with the #define macro. Compiling it with the GCC 2.8.1 (with -ansi) it OK. But when we are using the SUN C 5.0 compiler it screams. Following is a code sample: #include <stdlib.h> #include <stdio.h> typedef struct TEST3 {... (4 Replies)
Discussion started by: amatsaka
4 Replies

2. Programming

save a struct

hi all , can i save a structure in c in a file? how ? help me , thx. :) (2 Replies)
Discussion started by: kall_ANSI
2 Replies

3. Programming

struct tm problem

I receive an integer as argument for a function. within function definition i want it to be of type struct tm. eg.. main() { int a; ...... } function(...,..,a,..) int a; { struct tm tm; if(!a) ^ time(&a); ^ ... (4 Replies)
Discussion started by: bankpro
4 Replies

4. Programming

Struct Array

in my .c file i have a struct atop of the program defined as follows: #define MAX 10 int curtab; static struct tab { int count; int use; } tab; with the initial function following it like so: int tab_create(int init_count) { int i; for(i=0; i < MAX; i++) {... (1 Reply)
Discussion started by: micmac700
1 Replies

5. Linux

GCOV : struct bb

Hi, I am working on gcov.Meaning, analysing the functionality of gcov. There is one structure called "struct bb". I am not sure, how struct bb members are getting assigned values. If anyone knows how it is happening pls let me know. Thanks in advance. --Vichu (0 Replies)
Discussion started by: Vichu
0 Replies

6. UNIX for Dummies Questions & Answers

How to access a struct within a struct?

Can someone tell me how to do this? Just a thought that entered my mind when learning about structs. First thought was: struct one { struct two; } struct two { three; } one->two->three would this be how you would access "three"? (1 Reply)
Discussion started by: unbelievable21
1 Replies

7. UNIX for Dummies Questions & Answers

struct winsize

what is struct winsize used for? i tried looking it up, but no luck. (0 Replies)
Discussion started by: l flipboi l
0 Replies

8. Shell Programming and Scripting

converting from c struct to function

Hey Guys, I need your help where I have a C structure and I want it to be converted into corresponding function. Example: typedef struct { unsigned long LineNum; //1025-4032 unsigned short KeyNum; /*tbd*/ char Key; /*between 1-3*/... (1 Reply)
Discussion started by: skyos
1 Replies

9. Programming

Storing C++-struct in file - problem when adding new item in struct

Hi, I have received an application that stores some properties in a file. The existing struct looks like this: struct TData { UINT uSizeIncludingStrings; // copy of Telnet data struct UINT uSize; // basic properties: TCHAR szHost; //defined in Sshconfig UINT iPortNr; TCHAR... (2 Replies)
Discussion started by: Powerponken
2 Replies

10. Programming

Get struct definition

I have many headers with huge amount of structures in them, typical one looks like this: $ cat a.h struct Rec1 { int f1; int f2; }; struct Rec2 { char r1; char r2; }; struct Rec3 { int f1; float k1; float ... (6 Replies)
Discussion started by: migurus
6 Replies
lf64(5) 						Standards, Environments, and Macros						   lf64(5)

NAME
lf64 - transitional interfaces for 64-bit file offsets DESCRIPTION
The data types, interfaces, and macros described on this page provide explicit access to 64-bit file offsets. They are accessible through the transitional compilation environment described on the lfcompile64(5) manual page. The function prototype and semantics of a transi- tional interface are equivalent to those of the standard version of the call, except that relevant data types are 64-bit entities. Data Types The following tables list the standard data or struct types in the left-hand column and their corresponding explicit 64-bit file offset types in the right-hand column, grouped by header. The absence of an entry in the left-hand column indicates that there is no existing explicit 32-bit type that corresponds to the 64-bit type listed in the right--hand column. Note that in a 64-bit application, the standard definition is equivalent to the 64-bit file offset definition. <aio.h> struct aiocb struct aiocb64 off_t aio_offset; off64_t aio_offset; <sys/dirent.h> struct dirent struct dirent64 ino_t d_ino; ino64_t d_ino; off_t d_off; off64_t d_off; <sys/fcntl.h> struct flock struct flock64 off_t l_start; off64_t l_start; off_t l_len; off64_t l_len; F_SETLK F_SETLK64 F_SETLKW F_SETLKW64 F_GETLK F_GETLK64 F_FREESP F_FREESP64 O_LARGEFILE <sys/stdio.h> fpos_t fpos64_t <sys/resource.h> rlim_t rlim64_t struct rlimit struct rlimit64 rlim_t rlim_cur; rlim64_t rlim_cur; rlim_t rlim_max; rlim64_t rlim_max; RLIM_INFINITY RLIM64_INFINITY RLIM_SAVED_MAX RLIM64_SAVED_MAX RLIM_SAVED_CUR RLIM64_SAVED_CUR <sys/stat.h> struct stat struct stat64 ino_t st_ino; ino64_t st_ino; off_t st_size; off64_t st_size; blkcnt_t st_blocks; blkcnt64_t st_blocks; <sys/statvfs.h> struct statvfs struct statvfs64 fsblkcnt_t f_blocks; fsblkcnt64_t f_blocks; fsblkcnt_t f_bfree; fsblkcnt64_t f_bfree; fsblkcnt_t f_bavial; fsblkcnt64_t f_bavial; fsfilcnt_t f_files; fsfilcnt64_t f_files; fsfilcnt_t f_ffree; fsfilcnt64_t f_ffree; fsfilcnt_t f_favail; fsfilcnt64_t f_favail; <sys/types.h> off_t; off64_t; ino_t; ino64_t; blkcnt_t; blkcnt64_t; fsblkcnt_t; fsblkcnt64_t; fsfilcnt_t; fsfilcnt64_t; <unistd.h> _LFS64_LARGEFILE _LFS64_STDIO <sys/unistd.h> _CS_LFS64_CFLAGS _CS_LFS64_LDFLAGS _CS_LFS64_LIBS _CS_LFS64_LINTFLAGS System Interfaces The following tables display the standard API and the corresponding transitional interfaces for 64-bit file offsets. The interfaces are grouped by header. The interface name and the affected data types are displayed in courier font. <aio.h> int aio_cancel(..., int aio_cancel64(..., struct aiocb *); struct aiocb64 *); int aio_error( int aio_error64( const struct aiocb *); const struct aiocb64 *); int aio_fsync(..., int aio_fsync64(..., struct aiocb *); struct aiocb64 *); int aio_read(struct aiocb *); int aio_read64(struct aiocb64 *); int aio_return(struct aiocb *); int aio_return64(struct aiocb64 *); int aio_suspend( int aio_suspend64( const struct aiocb *, ...); const struct aiocb64 *, ...); int aio_waitn(aiocb_t *[], int aio_waitn64(aiocb64_t *[], ...); ...); int aio_write(struct aiocb *); int aio_write64(struct aiocb64 *); int lio_listio(..., int lio_listio64(..., const struct aiocb *, ...); const struct aiocb64 *, ...); <dirent.h> int alphasort(const struct int alphasort64(const struct dirent **, const struct dirent64 **, const struct dirent **) dirent64 **) struct dirent *readdir(); struct dirent64 *readdir64(); struct dirent *readdir_r(); struct dirent64 *readdir64_r(); int scandir(..., struct int scandir64(..., struct dirent *(*[]), int dirent64 *(*[]), int (*)(const (*)(const struct dirent *), struct dirent64 *), int int (*)(const struct dirent (*)(const struct dirent64 **, **, const struct dirent const struct dirent64 **)) **)) <fcntl.h> int attropen(); int attropen64(); int creat(); int creat64(); int open(); int open64(); int openat(); int openat64(); <ftw.h> int ftw(..., int ftw64(..., const struct stat *, ...); const struct stat64 *, ...); int nftw(.. int nftw64(..., const struct stat *, ...); const struct stat64 *, ...); <libgen.h> char *copylist(..., off_t); char *copylist64(..., off64_t); <stdio.h> int fgetpos(); int fgetpos64(); FILE *fopen(); FILE *fopen64(); FILE *freopen(); FILE *freopen64(); int fseeko(..., off_t, ...); int fseeko64(..., off64_t, ...); int fsetpos(..., int fsetpos64(..., const fpos_t *); const fpos64_t *); off_t ftello(); off64_t ftello64()(); FILE *tmpfile(); FILE *tmpfile64(); <stdlib.h> int mkstemp(); int mkstemp64(); <sys/async.h> int aioread(..., off_t, ...); int aioread64(..., off64_t, ...); int aiowrite(..., off_t, ...); int aiowrite64(..., off64_t, ...); <sys/dirent.h> int getdents(..., dirent); int getdents64(..., dirent64); <sys/mman.h> void mmap(..., off_t); void mmap64(..., off64_t); <sys/resource.h> int getrlimit(..., int getrlimit64(..., struct rlimit *); struct rlimit64 *); int setrlimit(..., int setrlimit64(..., const struct rlimit *); const struct rlimit64 *); <sys/sendfile.h> ssize_t sendfile(..., ssize_t sendfile64(..., off_t *, ...); off64_t *, ...); ssize_t sendfilev(..., const ssize_t sendfilev64(..., const struct sendfilevec *, ...); struct sendfilevec64 *, ...); <sys/stat.h> int fstat(..., struct stat *); int fstat64(..., struct stat64 *); int fstatat(..., int fstatat64(..., struct stat *, int); struct stat64 *, int); int lstat(..., struct stat *); int lstat64(..., struct stat64 *); int stat(..., struct stat *); int stat64(..., struct stat64 *); <sys/statvfs.h> int statvfs(..., int statvfs64(..., struct statvfs *); struct statvfs64 *); int fstatvfs(..., int fstatvfs64(..., struct statvfs *); struct statvfs64 *); <ucbinclude/stdio.h> FILE *fopen() FILE *fopen64() FILE *freopen() FILE *freopen64() <ucbinclude/sys/dir.h> int alphasort( int alphasort64( struct direct **, struct direct64 **, struct direct **); struct direct64 **); struct direct *readdir(); struct direct64 *readdir64(); int scandir(..., int scandir64(..., struct direct *(*[]);, ...); struct direct64 *(*[]);, ...); <unistd.h> int lockf(..., off_t); int lockf64(..., off64_t); off_t lseek(..., off_t, ...); off64_t lseek64(..., off64_t, ...); int ftruncate(..., off_t); int ftruncate64..., off64_t); ssize_t pread(..., off_t); ssize_t pread64..., off64_t); ssize_t pwrite(..., off_t); ssize_t pwrite64(..., off64_t); int truncate(..., off_t); int truncate64(..., off64_t); SEE ALSO
lfcompile(5), lfcompile64(5) SunOS 5.10 5 May 2004 lf64(5)
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy