Function Prototypes Flashcards

1
Q

memcpy

A

void *memcpy(void *restrict dst, const void *restrict src, size_t n);

• Copies n bytes from memory area src to memory area dst

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

strcpy

A

char *stpcpy(char *dst, const char *src);

• Copies string src to dst

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

malloc

A

void *malloc(size_t size);

• Allocates block of memory and returns pointer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

calloc

A

void *calloc(size_t count, size_t size);

• Allocates space for count objects, fills with zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

realloc

A

void *realloc(void *ptr, size_t size);

• Change the size of memory pointed to by ptr to size, returns ptr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

free

A

void free(void *ptr);

• Deallocates memory allocation pointed to by ptr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

strdup

A

char *strdup(const char *s1);

• Allocates sufficient memory for a copy of the string s1, does the copy, and returns a pointer to it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

fopen

A

FILE *fopen(const char *restrict filename, const char *restrict mode);

• Opens file from filename and returns pointer to file stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

fdopen

A

FILE *fdopen(int fildes, const char *mode);

• Opens file from filedes and returns pointer to file stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

open

A

int open(const char *pathname, int flags);

• Open file at pathname for reading/writing, returns file descriptor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

close

A

int close(int fildes);

• Close file associated with file destination, returns 0 or -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

read

A

ssize_t read(int fildes, void *buf, size_t nbyte);

• Read nbyte bytes of data from fildes into the buffer pointed to by buf. Returns number of bytes read or -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

write

A

ssize_t write(int fildes, const void *buf, size_t nbyte);

• Write nbyte bytes of data from buffer pointed to by buf into the filedes file. Returns number of bytes written or -1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

lseek

A

off_t lseek(int fildes, off_t offset, int whence);

• Repositions the offset of the file descriptor fildes to the argument offset, according to the directive whence.

whence SEEK_SET = set to offset bytes
whence SEEK_CUR = current location plus bytes
whence SEEK_END = size of file plus bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

stat

A

int stat(const char *path, struct stat *buf);

• Obtains information about the file pointed to by path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

fstat

A

int fstat(int filedes, struct stat *buf);

• Obtains information about file descriptor fildes.

17
Q

lstat

A

int lstat(const char *path, struct stat *buf);

• Obtains information about the symbolic link

18
Q

opendir

A

DIR *opendir(const char *name);

• Opens the directory named by filename, associates a directory stream and returns pointer to it

19
Q

readdir

A

struct dirent *readdir(DIR *dirp);

• Returns a pointer to the next directory entry.

20
Q

getcwd

A

char *getcwd(char *buf, size_t size);

• Get the current working directory

21
Q

chdir

A

int chdir(const char *path);

• Change the current working directory to path, returns 0 or -1