There is no function that gives you current line. But you can use ftell function to get the offset in terms of number of char from the start of the file.
I need to add a string before the 45th byte in an existing file. I tried using fseek as shown below.
int main()
{
FILE *fp;
char str[] = "test";
fp = fopen(FILEPATH,"a");
fseek(fp,-45, SEEK_END);
fprintf(fp,"%s",…
I have a text file text.txt that reads (for simplicity purposes)
this is line one
this is line two
this is line three
Again for simplicity's sake, I am just trying to set the first character in each line …
How can I determine the list of files in a directory from inside my C or C++ code?
I'm not allowed to execute the ls command and parse the results from within my program.