made work: line numbers in files with the correct indentation level (tested on a > 1000 lines file)
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
// #include <stdio.h>
|
||||
// #include <odweta/util.h>
|
||||
//
|
||||
// int main() {
|
||||
// char* string = intToString(1729843);
|
||||
//
|
||||
// printf("final string: %s\n", string);
|
||||
//
|
||||
// char* sstring = intToString(123);
|
||||
//
|
||||
// printf("final string: %s\n", sstring);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
#include <odweta/file.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -10,7 +25,7 @@ int main() {
|
||||
|
||||
printf("\nconvering the file contents into a string (char*)\n");
|
||||
char* string = fileToString(f);
|
||||
printf("\"%s\"\n", string);
|
||||
printf("\"\"\"\n%s\"\"\"\n", string);
|
||||
|
||||
printf("writing is quite simple, just call the 'fileWrite(file_t*, char*)' or 'fileWriteln(file_t*, char*)' function, where the second argument is the string you want to write into a file\nthe 'fileWriteln()' function writes the specified string AND a '\\n' after it, whereas the 'fileWrite()' function does not append the '\\n'\n");
|
||||
fileWrite(f, "'this will not end with a \"\\n\"' ");
|
||||
@@ -40,9 +55,27 @@ int main() {
|
||||
filePrint(move_dst);
|
||||
|
||||
fileCleanup(src);
|
||||
printf("DO NOT cleanup a deleted file! (dst, in this case) it is already done for you by the 'fileMove(file_t*)' function\n");
|
||||
printf("DO NOT cleanup a deleted file! (dst, in this case) it is already done for you by the 'fileMove(file_t*, char*)' function\n");
|
||||
// fileCleanup(dst);
|
||||
fileCleanup(move_dst);
|
||||
|
||||
printf("when copying and moving files, the first argument is a file_t* (source file) and the second argument is a char* (the path of the destination file), not a file_t*!\n");
|
||||
|
||||
printf("prepending line numbers at the beggining of each line in a file\n");
|
||||
|
||||
file_t* g = fileInit("test.txt");
|
||||
fileCopy(g, "copy_of_test.txt");
|
||||
file_t* g_copy = fileInit("copy_of_test.txt");
|
||||
fileNumberLines(g_copy);
|
||||
|
||||
printf("file withOUT prepended numbers:\n");
|
||||
filePrint(g);
|
||||
|
||||
printf("file with prepended numbers:\n");
|
||||
filePrint(g_copy);
|
||||
|
||||
fileCleanup(g);
|
||||
//fileCleanup(g_copy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user