Click here to Skip to main content
16,005,236 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Testing if a file exists Pin
David Crow30-Mar-06 9:11
David Crow30-Mar-06 9:11 
AnswerRe: Testing if a file exists Pin
toxcct30-Mar-06 20:29
toxcct30-Mar-06 20:29 
QuestionWhy do I extract two different mp3 song durations? Pin
yongwpi30-Mar-06 6:35
yongwpi30-Mar-06 6:35 
AnswerRe: Why do I extract two different mp3 song durations? Pin
lastgen30-Mar-06 17:08
lastgen30-Mar-06 17:08 
GeneralRe: Why do I extract two different mp3 song durations? Pin
yongwpi31-Mar-06 4:13
yongwpi31-Mar-06 4:13 
Questiona suggestion Pin
yaaqub30-Mar-06 6:24
yaaqub30-Mar-06 6:24 
AnswerRe: a suggestion Pin
toxcct30-Mar-06 6:36
toxcct30-Mar-06 6:36 
QuestionDecode problem Pin
beardy janggut30-Mar-06 5:32
beardy janggut30-Mar-06 5:32 
//declare the binary in header file like<br />
//#define A "0000000"<br />
//#define B "0000001"<br />
void CMyPsmDlg::OnButtonEncode() <br />
{<br />
char bu;<br />
FILE *InFile,*Binary;<br />
InFile=fopen(SourceFileName,"r"); //SourceFileName is a CString object<br />
Binary1=fopen("Binary1.txt","w");<br />
while(true)<br />
{<br />
 bu=fgetc(InFile);<br />
  if(feof(InFile))<br />
  break;<br />
  if ((bu=='%'))<br />
  fprintf(Binary1,PERCENT);<br />
else if (bu==' ')<br />
     fprintf(Binary1,SPACE);<br />
else if ((bu=='1'))<br />
    fprintf(Binary1,N1);<br />
else if ((bu=='2'))<br />
     fprintf(Binary1,N2);<br />
//change every character in the source file to binary and print it <br />
//at Binary1.txt<br />
fclose(Infile);<br />
 fclose(Binary);<br />
}<br />
<br />
FILE *Carrier, *Binary1,*LastOutput1;<br />
Carrier=fopen(CarrierFileName,"r");<br />
Binary1=fopen("Binary1.txt","r");<br />
LastOutput1=fopen("OutputFileName.txt","w");<br />
char BinaryBuffer,CarrierBuffer;<br />
//<br />
while (true)<br />
{<br />
CarrierBuffer=fgetc(Carrier);<br />
if(feof(Carrier))<br />
break;<br />
else  if (CarrierBuffer=='A')<br />
    fprintf(LastOutput1,"A");<br />
else if (CarrierBuffer=='B')<br />
    fprintf(LastOutput1,"B");<br />
else if (CarrierBuffer=='C')<br />
    fprintf(LastOutput1,"C");<br />
//until all characters in keyboard<br />
else if (CarrierBuffer==' ')<br />
	{<br />
		BinaryBuffer=fgetc(Binary1);<br />
		if(feof(Binary1))<br />
		fprintf(LastOutput1," ");<br />
		else if (BinaryBuffer=='1')<br />
		   fprintf(LastOutput1,"   ");//double space<br />
			else if (BinaryBuffer=='0')<br />
		   fprintf(LastOutput1," ");<br />
	}<br />
	<br />
}<br />
<br />
}<br />
void CMyPsmDlg::OnButtonDecode()<br />
{<br />
char BinaryBuffer2[8],SpaceBinBuff;<br />
FILE *Binary2,*LastOutputDecode,*LastOutputEncode;<br />
Binary2=fopen("Binary2.txt","w");<br />
LastOutputEncode=fopen("OutputFileName.txt","r");<br />
while (true)<br />
{<br />
SpaceBinBuff=fgetc(LastOutputEncode);<br />
if (feof(LastOutputEncode))<br />
  break;<br />
if (SpaceBinBuff==' ' && fgetc(LastOutputEncode) == ' ')<br />
	{	<br />
fprintf(Binary2,"1");<br />
	}<br />
else if (SpaceBinBuff==' ')<br />
	{<br />
	fprintf(Binary2,"0");<br />
	}<br />
}<br />
fclose(Binary2);<br />
fclose(LastOutputEncode);<br />
FILE *Binary2;<br />
Binary2=fopen("Binary2.txt","r");<br />
 LastOutputDecode=fopen( "AfterDecode.txt","w");<br />
while(true)<br />
{   <br />
  fgets(BinaryBuffer2,8,Binary3);<br />
  if(feof(Binary3))<br />
    break;<br />
<br />
  if (strcmp(BinaryBuffer2,A)==0)<br />
    fprintf(LastOutputDecode,"A");<br />
<br />
else if (strcmp(BinaryBuffer2,B)==0)<br />
    fprintf(LastOutputDecode,"B");<br />
<br />
else if (strcmp(BinaryBuffer2,C)==0)<br />
    fprintf(LastOutputDecode,"C");<br />
//until all char in keyboard<br />
fclose(LastOutputDecode);<br />
 fclose(Binary3);<br />
<br />
} 
The problem is when i decode, there are a stream of AAAAAAAAA.. at the end of file decoded. How can i eliminate this?


HelpMe

-- modified at 11:42 Thursday 30th March, 2006
AnswerRe: Decode problem Pin
David Crow30-Mar-06 5:44
David Crow30-Mar-06 5:44 
Questionabout RegisterWindowMessage and register a system hotkey Pin
FlyWithYou30-Mar-06 5:28
FlyWithYou30-Mar-06 5:28 
QuestionStack overflow message Pin
Clay L30-Mar-06 5:27
Clay L30-Mar-06 5:27 
QuestionRe: Stack overflow message Pin
David Crow30-Mar-06 5:40
David Crow30-Mar-06 5:40 
AnswerRe: Stack overflow message Pin
Clay L30-Mar-06 9:43
Clay L30-Mar-06 9:43 
Questionchange to binary Pin
beardy janggut30-Mar-06 5:10
beardy janggut30-Mar-06 5:10 
AnswerRe: change to binary Pin
Rage30-Mar-06 5:24
professionalRage30-Mar-06 5:24 
QuestionRe: change to binary Pin
David Crow30-Mar-06 5:30
David Crow30-Mar-06 5:30 
AnswerRe: change to binary Pin
Rage30-Mar-06 5:52
professionalRage30-Mar-06 5:52 
GeneralRe: change to binary Pin
beardy janggut30-Mar-06 20:26
beardy janggut30-Mar-06 20:26 
QuestionRe: change to binary Pin
David Crow30-Mar-06 5:25
David Crow30-Mar-06 5:25 
QuestionHow do get the Print Out Pin
rameshmahadevan30-Mar-06 4:41
rameshmahadevan30-Mar-06 4:41 
QuestionRe: How do get the Print Out Pin
David Crow30-Mar-06 4:48
David Crow30-Mar-06 4:48 
AnswerRe: How do get the Print Out Pin
Waldermort30-Mar-06 5:14
Waldermort30-Mar-06 5:14 
GeneralRe: How do get the Print Out Pin
David Crow30-Mar-06 5:22
David Crow30-Mar-06 5:22 
GeneralRe: How do get the Print Out Pin
Waldermort30-Mar-06 5:58
Waldermort30-Mar-06 5:58 
GeneralRe: How do get the Print Out Pin
normanS30-Mar-06 19:00
normanS30-Mar-06 19:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.