Bonjour tout le monde,
j'ai vraiment besoin d'aide svp. En fait j'ai une page codée en C++ que je voudrais convertir en C.
Y'a pas tellement de différences mais y'a des trucs qui me dépassent, comme par exemple la bibliothèque "stream" qui est propre à C++, ofstream, iftream, &output, output_unit, etc...
Je voudrais que vous me recodez mes fonctions (que j'ai extrait de la page) en C SVP ???
Voici les fonctions (j'ai mis en gras ce qui m'échappe):
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <cstring>
# include <fstream>
# include <cmath>
# include <ctime>
using namespace std;
# include "cnf_io.H"
//***************************************************************************80
bool cnf_data_read ( string cnf_file_name, int v_num, int c_num,
int l_num, int l_c_num[], int l_val[] )
//****************************************************************************80
{
int c_num2;
bool error;
int ierror;
ifstream input;
int l_c_num2;
int l_num2;
int l_val2;
int length;
string line;
string rest;
int v_num2;
string word;
error = false;
input.open ( cnf_file_name.c_str ( ) );
if ( !input )
{
cout << "\n";
cout << "CNF_DATA_READ - Fatal error!\n";
cout << " Could not open file.\n";
exit ( 1 );
}
while ( 1 )
{
getline ( input, line );
if ( input.eof ( ) )
{
cout << "\n";
cout << "CNF_DATA_READ - Fatal error!\n";
cout << " Error3 while reading the file.\n";
exit ( 1 );
}
if ( line[0] == 'c' || line[0] == 'C' )
{
continue;
}
}
;
while ( 1 )
{
getline ( input, line );
if ( input.eof ( ) )
{
break;
}
input.close ( );
return ;
}
//****************************************************************************80
bool cnf_data_write ( int c_num, int l_num, int l_c_num[], int l_val[],
ofstream &output_unit )
//****************************************************************************80
{
int c;
bool error;
int i1;
int i2;
int l;
int l_c;
error = false;
l = 0;
for ( c = 0; c < c_num; c++ )
{
i1 = 1;
i2 = 10;
for ( l_c = 0; l_c < l_c_num[c]; l_c++ )
{
output_unit << " " << setw(7) << l_val[l];
l = l + 1;
if ( ( ( l_c + 1 ) % 10 ) == 0 )
{
output_unit << "\n";
}
}
output_unit << " " << setw(7) << 0 << "\n";
}
return error;
}