Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

It was working correctly a while ago. But i dont know what was is the error.

My Code:

char oldfn[] = "d://booksdata.txt";
char newfn[] = "d://booksdata_temp.txt";
remove(oldfn);
rename(newfn, oldfn);

Remove function works correctly but my rename function does not work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
315 views
Welcome To Ask or Share your Answers For Others

1 Answer

From ISO/IEC9899:

7.19.4.2 The rename function

Synopsis

1 #include < stdio.h>

int rename(const char *old, const char *new);

As you can see by the prototype: you are using the old and new arguments in the wrong place.

Just switch then and one error is fixed. If there is still one... Tell us the error text please.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...