![]() ![]() If ( strncmp( q, playerName, len ) = 0 ) // found name? namesomeothervalue\nĬhar* q = strchr( p, *playerName ) // look for first letter in playerName file format assumed to be as specified in the question i.e. Static size_t deleteLine( char* buffer, size_t size, const char* playerName ) Size_t newSize = deleteLine( buffer, st.st_size, argv ) If ( fread(buffer, 1, st.st_size, fp) = st.st_size) Static size_t deleteLine( char*, size_t, const char* ) fopen()ĮDIT: the above solution would work fine with a small file but as by comment it is not suitable for a large file so here comes an alternative solution (GCC C99) which reads in the whole file, finds the name then moves the lines after that line forward in the buffer. Then copy line by line and skip the line you want to deleteĪfter you are done, delete the old file and rename the new one to the old name. One simple method is to open two files, one in and one out. There are several ways you can delete a line, ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |