Permalink
Browse files

Cleaned up.

  • Loading branch information...
1 parent 9f8cbaf commit e17368c9d103f3f300343630e43cadbcbef14382 @richo richo committed Apr 11, 2011
Showing with 8 additions and 13 deletions.
  1. +5 −0 struct_alter/data.h
  2. +1 −8 struct_alter/read.c
  3. +2 −5 struct_alter/write.c
View
@@ -0,0 +1,5 @@
+struct t {
+ int g;
+ char m[50];
+};
+
View
@@ -1,23 +1,16 @@
#include <stdio.h>
-struct t {
- int g;
- char m[50];
-};
+#include "data.h"
int main() {
FILE *f;
int n;
struct t b;
- //b.g = 50;
- //b.m = *"1234512345123451234512345123451234512345123451233";
-
f = fopen("filename.bin", "rb");
if (f)
{
n = fread((void *) &b, sizeof(b), 1, f);
printf("%i", b.g);
- //n = fwrite((void *) &b, sizeof(b), 1, f);
}
else
{
View
@@ -1,20 +1,17 @@
#include <stdio.h>
-struct t {
- int g;
- char m[50];
-};
+#include "data.h"
int main() {
FILE *f;
int n;
struct t b;
+ // Add some arbitrary data here, who cares what.
b.g = 50;
f = fopen("filename.bin", "wb");
if (f)
{
- //n = fread(buffer, MAX_FILE_SIZE, 1, f);
n = fwrite((void *) &b, sizeof(b), 1, f);
}
else

0 comments on commit e17368c

Please sign in to comment.