1. ## a question files

hi ppl

how can write a data such as ( 0.7) to a file in a size which is smallest
that is not a float , i want the least size that i can

another question plz:
if i write to a file the ascii of a number and i want to read it from the file ,will the c++ program understand it as the original number
ex:
putc(myfile,56);

if i want to do
getc(myfile);
will the received char be the 56 ??????

amin!

2. how can write a data such as ( 0.7) to a file in a size which is smallest
that is not a float , i want the least size that i can

I have no idea what you mean. Try to word your sentences using
grammer that everyone can understand.

3. If you want to treat an ascii representation as a number then you need to convert it, you can use atoi() or since you want a decimel point atof()

4. how can write a data such as ( 0.7) to a file in a size which is smallest
that is not a float , i want the least size that i can
I understand your question, but I don't know the answer. A float can hold from 1.2 x 10exp-23 to 3.4x10exp38, and all you want to store is a little .7 without wasting all those extra bits. I'm sure someone here will be able to tell you how to do that.

if i write to a file the ascii of a number and i want to read it from the file ,will the c++ program understand it as the original number
ex:
putc(myfile,56);

if i want to do
getc(myfile);
will the received char be the 56 ??????
First, it looks like you have your arguments backwards:
Code:
int putc( int ch, FILE *stream );
When I try this:

putc(56, file1);

It writes an 8 to file1. When I try this:

char ch = getc(file1);

and then display it to the console window, I get an 8. But, I believe the act of displaying it, converts the ASCII 56 in the variable to an 8.

Since an ASCII 56 produces an 8 in the file, I can set up a test. I will write 56 to file1, close file1, open file1, then do this:

char ch;
getc(ch, file1);

I won't know what is in ch at this point. But, if I write ch to a second file, and it produces an 8, then I will have this situation:

putc(56, file1)----->8
putc(ch, file2)----->8

and that can only mean that ch is ASCII 56. Here goes...................there is an 8 in both files.

5. I just found a trick for outputting the ASCII code of a char. You can do this:

Code:
char ch;
ch=getc(ch, file1);

int  ascii_code = ch;
cout<<ch; //display the character
cout<<ascii_code; //display the ascii code
I think the lesson is: with a char type, C++ will convert the ascii number stored in the variable to the character whenever you try to display it, whether in a file or in the console window. If you want to actually see the ascii code, you need to convert the char variable to an int.