C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-28-2007, 07:28 PM   #1
Registered User
 
Join Date: Apr 2007
Posts: 12
using fopen getting a lot of warnings

Hello,

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);
}
thanks.
netiad is offline   Reply With Quote
Old 04-28-2007, 08:44 PM   #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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 09:24 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22