Click here to Skip to main content
15,908,901 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Slow Vista Drawing Pin
Koolski3-Feb-09 1:27
Koolski3-Feb-09 1:27 
QuestionRe: Slow Vista Drawing Pin
Koolski3-Feb-09 4:07
Koolski3-Feb-09 4:07 
GeneralFSCTL_GET_VOLUME_BITMAP FAT32 problem Pin
tudorigorian2-Feb-09 8:07
tudorigorian2-Feb-09 8:07 
QuestionTranslation (.rc) String tables Pin
Software20072-Feb-09 5:50
Software20072-Feb-09 5:50 
AnswerRe: Translation (.rc) String tables Pin
Code-o-mat2-Feb-09 8:41
Code-o-mat2-Feb-09 8:41 
GeneralRe: Translation (.rc) String tables Pin
CPallini2-Feb-09 9:07
mveCPallini2-Feb-09 9:07 
AnswerRe: Translation (.rc) String tables Pin
CPallini2-Feb-09 9:00
mveCPallini2-Feb-09 9:00 
Questionfloating point error in C++ Pin
Vivek Narayanan2-Feb-09 5:45
Vivek Narayanan2-Feb-09 5:45 
I wrote this code for a school project,since i use vista and dos doesn't work properly on it ,i normally use the emulator DOSBOX.The problem is this program runs well on DOSBOX but not on the normal DOS platform. It gives an error

<code> Floating point error:domain Abnormal program termination</code>
Here's the code,its on text file encryption.My school requires me to use the ancient "turbo c++ 3.0"

<pre>#include<string.h>
#include<stdio.h>
#include<fstream.h>
#include<conio.h>
#include<math.h>

int strtoken(char k[]) {
int N = strlen(k);
int sum = 0 ;

for (int q=0;q<N;q++)
sum+= (int) k[q] ;

int tok = sum%255;

return tok;
}

int strtoken2(char k1[]) {

int N1 = strlen(k1);
int sum1 = 0,t=0;
for (int q1=0;q1<N1;q1++)
{
t = (int) k1[q1];
t=pow(2,t);
sum1+= (t%255) ;
}

int tok = sum1%255;

return tok;
}


int main() {
clrscr();
int choice,num;
char ifname[20],ofname[20],Key[20],ch;

start:
clrscr();
cout<<"\n------------------------------------------------------------------------------\n";
cout<<"Texcrypt 1.0.\n";
cout<<"\n";
cout<<"------------------------------------------------------------------------------\n\n";
cout<<"\t\t\t*-------------------*\n"<<"\t\t\t| 1) Encrypt. |\n"<<"\t\t\t| 2) Decrypt. |\n"<<"\t\t\t| 3) Help. |\n\t\t\t| 4) Exit. |\n"<<"\t\t\t*-------------------*\n";
cout<<"\nEnter your choice: ";

cin>>choice;




if(choice==3) {
clrscr();

cout<<" Instructions \n ------------- \n\n\n 1.Choose whether to encrypt or decrypt a file ";
cout<<"\n 2.Enter the input and output filenames (if the file is in same directory as texcrypt ,if not,then enter the full path of the file)";
cout<<"\n 3.Enter the key to encrypt/decrypt the file with(your file will be encrypted on the basis of the key entered).";
cout<<"\n 4.The output file will be your encrypted/decrypted file";
cout<<"\n\n\n\nPress any key to return ...... ";

getch();

goto start;






}






else if(choice==4)
return 0;
char text[3][20] = {"","encrypted","decrypted"};

clrscr();
cout<<"Enter input filename : ";
gets(ifname);
fflush(stdin);
cout<<"\n";
int i;

ifstream infile("");
ofstream outfile("");
infile.open(ifname);

if(!infile) { // if file is not found
cout<<"Error:File not found";
goto end;
}

cout<<"Enter output filename : ";gets(ofname);fflush(stdin);
cout<<"\n";







outfile.open(ofname);


switch(choice) {

case 1:cout<<"Enter key: ";

for(i=0;;i++)
{


Key[i]=getch();


if (Key[i] == '\r')
break;
cout<<"*";
}
Key[i] = '\0';
<b>
<big>// I think the error is somewhere overhere</big></b>
int token= strtoken(Key);
int token2= strtoken2(Key);

fflush(stdin);
cout<<"\n";

while (infile) {

while(infile){

infile.get(ch);
if(!infile){
cout<<"\nThe file was successfully encrypted.";
getch();
goto end;
}

ch=char((ch+token-(token2))%255);

outfile.put(ch);
}
}

break;


case 2:
cout<<"Enter key: ";

for(i=0;;i++){
Key[i]=getch();


if (Key[i] == '\r')
break;
cout<<"*";

}
Key[i] = '\0';
cout<<"\n";
fflush(stdin);
int dtoken=strtoken(Key);
int dtoken2=strtoken2(Key);

while(infile) {

while(infile) {

infile.get(ch);
if(!infile)
{
cout<<"\nThe file was successfully decrypted.";
getch();
goto end;
}
ch=char(((ch)-dtoken+(dtoken2))%255);
outfile.put(ch);

}
}
break;
}
//end switch
end:
infile.close();
outfile.close();

cout<<"\n\n\nPress any key to return ......... " ;

getch();
goto start;

return 0;
}
</pre>
AnswerRe: floating point error in C++ Pin
David Crow2-Feb-09 5:51
David Crow2-Feb-09 5:51 
GeneralRe: floating point error in C++ Pin
Vivek Narayanan2-Feb-09 6:30
Vivek Narayanan2-Feb-09 6:30 
QuestionRe: floating point error in C++ Pin
David Crow2-Feb-09 7:21
David Crow2-Feb-09 7:21 
AnswerRe: floating point error in C++ Pin
Vivek Narayanan3-Feb-09 3:54
Vivek Narayanan3-Feb-09 3:54 
AnswerRe: floating point error in C++ Pin
Koolski2-Feb-09 9:56
Koolski2-Feb-09 9:56 
Questionencode wave to ogg [modified] Pin
Daerner Mandla2-Feb-09 5:08
Daerner Mandla2-Feb-09 5:08 
QuestionConverting Microsoft Visual C/C++ version 2.0 solution to Visual C++ 2005/2008 Pin
Cosmin Ciuraru2-Feb-09 3:56
Cosmin Ciuraru2-Feb-09 3:56 
AnswerRe: Converting Microsoft Visual C/C++ version 2.0 solution to Visual C++ 2005/2008 Pin
Iain Clarke, Warrior Programmer2-Feb-09 4:52
Iain Clarke, Warrior Programmer2-Feb-09 4:52 
QuestionError: Debug assertion failed! Pin
sam_psycho2-Feb-09 3:38
sam_psycho2-Feb-09 3:38 
AnswerRe: Error: Debug assertion failed! Pin
Code-o-mat2-Feb-09 3:41
Code-o-mat2-Feb-09 3:41 
GeneralRe: Error: Debug assertion failed! Pin
sam_psycho2-Feb-09 3:47
sam_psycho2-Feb-09 3:47 
GeneralRe: Error: Debug assertion failed! Pin
Code-o-mat2-Feb-09 4:03
Code-o-mat2-Feb-09 4:03 
AnswerRe: Error: Debug assertion failed! Pin
Iain Clarke, Warrior Programmer2-Feb-09 4:26
Iain Clarke, Warrior Programmer2-Feb-09 4:26 
AnswerRe: Error: Debug assertion failed! Pin
David Crow2-Feb-09 5:44
David Crow2-Feb-09 5:44 
Questionstatic Picture control not loading a bmp Pin
VC++Maniac2-Feb-09 1:36
VC++Maniac2-Feb-09 1:36 
AnswerRe: static Picture control not loading a bmp Pin
Hamid_RT2-Feb-09 3:19
Hamid_RT2-Feb-09 3:19 
GeneralRe: static Picture control not loading a bmp Pin
VC++Maniac2-Feb-09 3:20
VC++Maniac2-Feb-09 3:20 

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.