Hi,

I wish to remove the extra unwanted characters in the file name.

f1::f1(char *filename1)
{
        char file_txt[40];
        strcpy(file_txt,filename1);
        strcat(file_txt,".txt");

        system("rm file_txt");
}

In debug mode when i check the value of file_txt i get :
file_txt = "../../input.txt\000\000\000\000F\000\000\000\001\000\000\000\001\000\000\000\v\000\000\000\002\000\000\000\000\000\000\000\001\000\000"

I do not know hoe to get rid of the extra characters "\000\000\000" at the end of the file name.
Any help is appreciated.

Thanks

No need to truncate filename: zero byte logically terminates C-style text strings.
Better think about another (true) problem: what happens if filename contents length is greater than 40 - 1 (zero byte) - 4 (extension length) == 35...
Tip: you will get the program crash...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.