Usermode - heap debugging and memmove speedup
[tpg/acess2.git] / Usermode / Applications / writetest_src / main.c
1 /*
2  * Write test
3  */
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
7
8 // === CONSTANTS ===
9 int main(int argc, char *argv[])
10 {
11         FILE    *fp;
12         char    *file;
13         char    *text;
14         
15         // Check arguments
16         if(argc < 3) {
17                 fprintf(stderr, "Usage: %s <file> \"<text>\"\n", argv[0]);
18                 return EXIT_FAILURE;
19         }
20         
21         //file = argv[1];
22         //text = argv[2];
23         file = "/Mount/writetest.txt";
24         text = "Written!\n";
25         
26         printf("Testing File Output...\n");
27         printf("file = '%s'\n", file);
28         printf("text = \"%s\"\n", text);
29         
30         // Open file
31         fp = fopen(file, "w");
32         if(!fp) {
33                 fprintf(stderr, "Unable to open '%s' for writing\n", file);
34                 return EXIT_FAILURE;
35         }
36         
37         //printf("fwrite('%s', %i, 1, %p)\n", argv[2], strlen(argv[2]), fp);
38         if( fwrite(text, strlen(text), 1, fp) == -1 )
39         {
40                 fprintf(stderr, "Unable to write to '%s'\n", file);
41                 return EXIT_FAILURE;
42         }
43         fclose(fp);
44         
45         printf("Wow, It worked!\n");
46         
47         return EXIT_SUCCESS;
48 }

UCC git Repository :: git.ucc.asn.au