Take this one such example
http://www.daniweb.com/forums/post1228489.html#post1228489
int writefile(char *str, int size)
{
uint32_t c;
ofstream outfile;
outfile.open("output.txt");
for(int i=0;i>array[i];
printf("value fetched from file: %.8x\n", array[i]);
}
hash = array[ctr];
printf("Current value fetched from file: %.8x\n", hash);
myfile.close();
return hash;
}
int main()
{
//uint32_t c;
//int ctr =0;
char str[80];
cout<<"enter string: ";
cin.get(str,80);
cout<>array[i];
printf("value fetched from file: %.8x\n", array[i]);
}
hash = array[ctr];
printf("value fetched from file: %.8x\n", hash);
myfile.close();
*/
}
Ok if you quote it you can see indentation has been used but it is still pretty much awful.
After beautification:
int writefile ( char *str, int size )
{
uint32_t c;
ofstream outfile;
outfile.open ( "output.txt" );
for ( int i = 0; i < size; i++ )
{
c = hashlittle ( str, strlen ( str ), 0 );
printf ( "%.8x\n", c );
outfile << c << endl;
sprintf ( str, "%u", c );
}
outfile.close();
return 1;
}
uint32_t fetchfile ( int ctr )
{
uint32_t hash, array[10];
;
ifstream myfile ( "output.txt" );
myfile.is_open();
for ( int i = 0; i < 10; i++ )
{
myfile >> array[i];
printf ( "value fetched from file: %.8x\n", array[i] );
}
hash = array[ctr];
printf ( "Current value fetched from file: %.8x\n", hash );
myfile.close();
return hash;
}
int main()
{
//uint32_t c;
//int ctr =0;
char str[80];
cout << "enter string: ";
cin.get ( str, 80 );
cout << endl;
writefile ( str, 10 );
fetchfile ( 0 );
return 0;
/*
ofstream outfile;
outfile.open("output.txt");
for(int i=0; i<10; i++)
{
c = hashlittle(str, strlen(str), 0);
printf("%.8x\n", c);
outfile<<c<<endl;
sprintf(str, "%u", c);
}
uint32_t hash, array[10]; ;
ifstream myfile ("output.txt");
myfile.is_open();
for(int i=0; i<10; i++)
{
myfile>>array[i];
printf("value fetched from file: %.8x\n", array[i]);
}
hash = array[ctr];
printf("value fetched from file: %.8x\n", hash);
myfile.close();
*/
}
After beautifcation removing comments...
int writefile ( char *str, int size )
{
uint32_t c;
ofstream outfile;
outfile.open ( "output.txt" );
for ( int i = 0; i < size; i++ )
{
c = hashlittle ( str, strlen ( str ), 0 );
printf ( "%.8x\n", c );
outfile << c << endl;
sprintf ( str, "%u", c );
}
outfile.close();
return 1;
}
uint32_t fetchfile ( int ctr )
{
uint32_t hash, array[10];
;
ifstream myfile ( "output.txt" );
myfile.is_open();
for ( int i = 0; i < 10; i++ )
{
myfile >> array[i];
printf ( "value fetched from file: %.8x\n", array[i] );
}
hash = array[ctr];
printf ( "Current value fetched from file: %.8x\n", hash );
myfile.close();
return hash;
}
int main()
{
char str[80];
cout << "enter string: ";
cin.get ( str, 80 );
cout << endl;
writefile ( str, 10 );
fetchfile ( 0 );
return 0;
}