Beruflich Dokumente
Kultur Dokumente
File Handling in C
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
Topics
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
Streams
http://thumbs.dreamstime.com/z/binary-data-stream-19093118.jpg
JMC Yap CS 11 - File Input and Output
Streams
File Handling in C
More on streams
More on streams
More on streams
More on streams
More on streams
More on streams
More on streams
Kinds of streams
Kinds of streams
Text stream
Kinds of streams
Binary stream
Topics
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
Topics
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
FILE *input_file;
...
if (input_file == NULL) {
printf(" File /home/user/practice2.c does not exist!\n");
}
...
fclose(windows_input_file);
fclose(unix_input_file);
fclose(input_file);
Topics
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
#include <stdio.h>
main() {
FILE *input_file = fopen("/home/user/practice.c", "r");
char file_char;
fclose(input_file);
}
#include <stdio.h>
main() {
FILE *input_file = fopen("/home/user/practice.c", "r");
char file_line[101];
fclose(input_file);
}
Writing to a file
Writing to a file
Writing to a file
Writing to a file
Writing to a file
#include <stdio.h>
main() {
int x[2][3] = {{22, 23, 24}, {101, 102, 105}};
int i, j;
#include <stdio.h>
main() {
FILE *output = fopen("./poem.out", "w");
fputs("Roses are red,\n", output);
fputs("Violets are blue,\n", output);
fputs("Rhyming is overrated,\n", output);
fputs("Zebra.\n", output);
fclose(output);
}
Topics
1 Streams
2 File Handling in C
File Pointer
File I/O
Some Notes
String to integer
atoi(<string variable name>);
atol(<string variable name>); // for long int
String to integer
atoi(<string variable name>);
atol(<string variable name>); // for long int
String to float
atof(<string variable name>);
String to integer
atoi(<string variable name>);
atol(<string variable name>); // for long int
String to float
atof(<string variable name>);
Numbers to string
sprintf(<string variable>, "%d", <int variable>);
sprintf(<string variable>, "%ld", <long int variable>);
sprintf(<string variable>, "%f", <float variable>);
sprintf(<string variable>, "%lf", <double variable>);
END OF LESSON 8