N
Niv (KP)
I've downloaded Visual C++ from MicroSoft to start learing some some
simple 'C', particularly file I/O.
I copied this programme for "Teach yourself C...." but I'm getting
these warnings, although the prog does run.
///////////////////////////////////////////////////////////start of
prog
#include <stdio.h>
enum {SUCCESS, FAIL};
void CharReadWrite(FILE *fin, FILE *fout);
int main(void)
{
FILE *fptr1, *fptr2;
char fname1[]= "c:/vcpp/data_bytes.txt";
char fname2[]= "c:/vcpp/outp_bytes.txt";
int worked = SUCCESS;
if ((fptr1 = fopen(fname1, "r")) == NULL){
printf("Cannot open read file!");
worked = FAIL;
} else if ((fptr2 = fopen(fname2, "w")) == NULL){
printf("Cannot open write file!");
worked = FAIL;
} else {
CharReadWrite(fptr1, fptr2);
fclose(fptr1);
fclose(fptr2);
}
return worked;
}
// Function definition:
void CharReadWrite(FILE *fin, FILE *fout)
{
int c;
while ((c=fgetc(fin)) != EOF){
fputc(c,fout); // Write char to out-file.
putchar(c);
}
}
///////////////////////////end of prog.
Error messages are;
------ Build started: Project: file_read, Configuration: Debug Win32
------
Compiling...
cl : Command line warning D9035 : option 'Wp64' has been deprecated
and will be removed in a future release
file_read.cpp
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(15) : warning C4996: 'fopen': This function
or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h
(237) : see declaration of 'fopen'
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(18) : warning C4996: 'fopen': This function
or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h
(237) : see declaration of 'fopen'
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(32) : warning C4101: 'i' : unreferenced local
variable
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
Embedding manifest...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build log was saved at "file://c:\Documents and Settings\Niv\My
Documents\Visual Studio 2008\projects\file_read\Debug\BuildLog.htm"
file_read - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped
==========
Can someone tell me what to do to get rid of these warnings please?
I dabbled in C years ago, but the modern compilers seem to do a lot
more (like confuse!).
simple 'C', particularly file I/O.
I copied this programme for "Teach yourself C...." but I'm getting
these warnings, although the prog does run.
///////////////////////////////////////////////////////////start of
prog
#include <stdio.h>
enum {SUCCESS, FAIL};
void CharReadWrite(FILE *fin, FILE *fout);
int main(void)
{
FILE *fptr1, *fptr2;
char fname1[]= "c:/vcpp/data_bytes.txt";
char fname2[]= "c:/vcpp/outp_bytes.txt";
int worked = SUCCESS;
if ((fptr1 = fopen(fname1, "r")) == NULL){
printf("Cannot open read file!");
worked = FAIL;
} else if ((fptr2 = fopen(fname2, "w")) == NULL){
printf("Cannot open write file!");
worked = FAIL;
} else {
CharReadWrite(fptr1, fptr2);
fclose(fptr1);
fclose(fptr2);
}
return worked;
}
// Function definition:
void CharReadWrite(FILE *fin, FILE *fout)
{
int c;
while ((c=fgetc(fin)) != EOF){
fputc(c,fout); // Write char to out-file.
putchar(c);
}
}
///////////////////////////end of prog.
Error messages are;
------ Build started: Project: file_read, Configuration: Debug Win32
------
Compiling...
cl : Command line warning D9035 : option 'Wp64' has been deprecated
and will be removed in a future release
file_read.cpp
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(15) : warning C4996: 'fopen': This function
or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h
(237) : see declaration of 'fopen'
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(18) : warning C4996: 'fopen': This function
or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\stdio.h
(237) : see declaration of 'fopen'
c:\documents and settings\niv\my documents\visual studio 2008\projects
\file_read\file_read.cpp(32) : warning C4101: 'i' : unreferenced local
variable
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
Embedding manifest...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Build log was saved at "file://c:\Documents and Settings\Niv\My
Documents\Visual Studio 2008\projects\file_read\Debug\BuildLog.htm"
file_read - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped
==========
Can someone tell me what to do to get rid of these warnings please?
I dabbled in C years ago, but the modern compilers seem to do a lot
more (like confuse!).