473,242 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

I got a fopen was declared deprecated warning

Hi.. All
I got a problem in writing this program
becoz I successfullly compiled the file
but I cannot run the program since there will be an error when I run it.
So I checked again... And there is only 1 warning left which was "fopen was declared deprecated" <--- maybe this is why I couldn't run the program successfullly?
I kinda noob in programming ... So I really need some help here
So Here I include my code here for anyone who can help me...
And thank you very much....

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stddef.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include<malloc.h>
  7. #include<fstream>
  8. #include<string.h>
  9. #include<time.h>
  10. using namespace std;
  11.  
  12. /* lots and lots and lots of code snipped */
  13. //    Initialization of X, H, and G
  14.  
  15.     if (data = fopen(FileSave,"w")){
  16. //    Begin - Students
  17.     i=0;
  18.  
  19.     for(count1=0; count1<N; ++count1){
  20.         for(count2=0; count2<N; ++count2){
  21.             for(count3=0; count3<L; ++ count3){
  22.  
  23.                 H0[count1][count2][count3] = randomco();
  24.                 H1[count1][count2][count3] = randomco();
  25.                 G0[count1][count2][count3] = randomco();
  26.                 G1[count1][count2][count3] = randomco();
  27.             }
  28.         }
  29.     }
  30.     for(int count1=0; count1<M; ++count1){
  31.         X[count1] = randomco();
  32.     }
  33.  
  34. /* more code removed */
  35.  
  36. int main()
  37. {
  38.        MatrixFIR();
  39. }
Feb 23 '08 #1
3 4872
sicarie
4,677 Expert Mod 4TB
Hi.. All
I got a problem in writing this program
becoz I successfullly compiled the file
but I cannot run the program since there will be an error when I run it.
So I checked again... And there is only 1 warning left which was "fopen was declared deprecated" <--- maybe this is why I couldn't run the program successfullly?
I kinda noob in programming ... So I really need some help here
So Here I include my code here for anyone who can help me...
And thank you very much....

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stddef.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include<malloc.h>
  7. #include<fstream>
  8. #include<string.h>
  9. #include<time.h>
  10. using namespace std;
  11.  
  12. /* lots and lots and lots of code snipped */
  13. //    Initialization of X, H, and G
  14.  
  15.     if (data = fopen(FileSave,"w")){
  16. //    Begin - Students
  17.     i=0;
  18.  
  19.     for(count1=0; count1<N; ++count1){
  20.         for(count2=0; count2<N; ++count2){
  21.             for(count3=0; count3<L; ++ count3){
  22.  
  23.                 H0[count1][count2][count3] = randomco();
  24.                 H1[count1][count2][count3] = randomco();
  25.                 G0[count1][count2][count3] = randomco();
  26.                 G1[count1][count2][count3] = randomco();
  27.             }
  28.         }
  29.     }
  30.     for(int count1=0; count1<M; ++count1){
  31.         X[count1] = randomco();
  32.     }
  33.  
  34. /* more code removed */
  35.  
  36. int main()
  37. {
  38.        MatrixFIR();
  39. }
Yes, fopen() is a C function. with C++ you declare a file stream, either input or output, so something like:

Expand|Select|Wrap|Line Numbers
  1. #include <fstream>
  2. /* .
  3.    .
  4.    .
  5. */
  6. ofstream f_outputFile;
  7. f_outputFile.open("myfile.txt");
  8. f_outputFile << variableWrittenToFile;
  9. f_outputFile.close();
  10. /* .
  11.    .
  12.    .
  13. */
  14.  
Also, even if you fix that, your program won't compile as you declare int main() but then return nothing at the end of the main function (standard is return 0;).
Feb 23 '08 #2
Yes, fopen() is a C function. with C++ you declare a file stream, either input or output, so something like:

Expand|Select|Wrap|Line Numbers
  1. #include <fstream>
  2. /* .
  3.    .
  4.    .
  5. */
  6. ofstream f_outputFile;
  7. f_outputFile.open("myfile.txt");
  8. f_outputFile << variableWrittenToFile;
  9. f_outputFile.close();
  10. /* .
  11.    .
  12.    .
  13. */
  14.  
Also, even if you fix that, your program won't compile as you declare int main() but then return nothing at the end of the main function (standard is return 0;).
Thank you for your reply... ^^
But then what should I return? at int main() ???
Feb 24 '08 #3
Laharl
849 Expert 512MB
Make the last statement in main() return 0; because if it reaches that point it has completed without error and 0 is the exit code for "no errors".
Feb 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
3
by: Ben Rush | last post by:
When I compile my solution I get the following output - NET 2003\Vc7\atlmfc\include\atlwin.h(2027) : warning C4995: 'wsprintf': name was marked as #pragma deprecated C:\Program Files\Microsoft...
7
by: Olaf Baeyens | last post by:
I am testing VC++ 2005 and I get this warning: "warning C4996: 'strncpy' was declared deprecated" Does that mean that they might be phased out in VC++ 2006 or higher? Or does an alternative...
185
by: Martin Jørgensen | last post by:
Hi, Consider: ------------ char stringinput ..bla. bla. bla. do {
1
by: zs | last post by:
Hi! I get warning message shown below in VS.NET 2k3. Is this deprecated by microsoft or by standard? I need hash_set to store and search small strings (<20 chars long). I'll have less then 300...
3
by: mrmattborja | last post by:
Hello, Here is a program I'm playing around with for fun in the process of learning C. The objective is to create a function filesize() and call it from within the main() section to retrieve the...
2
by: curious2007 | last post by:
I do not know how to handle this message: c:\users\admin\documents\visual studio 2005\projects\vec\vec\fileclass.cpp(40) : warning C4996: 'fopen' was declared deprecated c:\program...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
9
by: Eric | last post by:
I am working on a large, old code base and attempting to move it to GCC 4.2. Throughout the code, there is stuff like: char *aVar = "aString"; or void aFunc( char *aVar) { ... } aFunc(...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.