![]() |
| | #1 |
| Registered User Join Date: Apr 2007
Posts: 12
| using fopen getting a lot of warnings When I compile the below I get 2 warnings.... warning: deprecated conversion from string constant to char* How can I make this warning go away? I am using a lot of compile time warning flags by the way. Code: #include <stdio.h>
#include <stdlib.h>
void file_write (char file_path[], char text_to_write[]);
int main(){
file_write ("C:\\windows\\temp\\lala.txt", "Written by John");
return 0;
}
void file_write (char file_path[], char text_to_write[]){
FILE *file;
file = fopen(file_path, "wt");
fprintf (file, "%s", text_to_write);
fclose (file);
}
|
| netiad is offline | |
| | #2 |
| erstwhile Join Date: Jan 2002
Posts: 2,223
| Other than using a non-microsoft compiler, read the warning text as it should tell you exactly how to make it go away(a preprocessor definition, _CRT_SECURE_NO_DEPRECATE, probably). The warning can alternatively be ignored, unless you want to use one of microsoft's 'safe' alternatives.
__________________ CProgramming FAQ Caution: this person may be a carrier of the misinformation virus. |
| Ken Fitlike is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fopen and encoding of "*filename" argument. | techi_talk | C Programming | 4 | 05-16-2006 11:36 PM |
| fopen help. | chriscolden | C Programming | 17 | 01-13-2006 06:27 AM |
| fopen and CreateFile | Bajanine | Windows Programming | 3 | 04-03-2003 07:24 PM |
| Some errors and warnings i dont understand | lakai02 | C Programming | 6 | 10-18-2002 11:16 AM |
| Program chews up a lot of CPU when it closes | bman1176 | Windows Programming | 4 | 01-10-2002 11:23 AM |