Thread: Help with Program, I'm a newbie and I can't find the problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    2

    Help with Program, I'm a newbie and I can't find the problem

    I believe that I have everything written correctly in this program. It compiles fine, but when I try to run it It goes right past the cin statements without stopping to let me type something in, and then it runs the program like I had typed nothing in. I just started to use LInux as my full time OS, and that might be the problem, because I'm new to the oddities of programming in Linux, here is the source code.

    Code:
    #include<iostream.h>
    #include<stdlib.h>
    #include <cstdlib>
    #include <ctime>
    
    
    int main()
    {
    srand(time(0));
    unsigned short int pwrone = rand()%10;
    unsigned long int randone = (int)(rand() * 10^pwrone);
    pwrone = rand()%10;
    cout<<"Your First Encryption Number is : "<< randone <<"\n\n";
    char fake;
    cout<<"Press Enter to Continue";
    cin>>fake;
    unsigned short int pwrtwo = rand()%10;
    unsigned long int randtwo = (int)(rand() * 10^pwrtwo );
    pwrone = rand()%10;
    cout<<"Your Second Encryption Number is : "<< randone <<"\n\n";
    char message[500];
    cout<<"Please Enter the Message You Wish To Encrypt: ";
    short int messsize;
    cin.get(message, 500);
    messsize = scanf(message);
    cout<<"The size of the message is" <<messsize;
    //Start Encrypting Message
    int x=0;
    int ascii[500];
    for(int x=0; x<500; x++)
    {
    ascii[x] = message[x];
    }
    int y=0;
    int encrypted[500];
    cout<<"\n\n">
    cout<<"The Encrypted Message Is: \n";
    cout<<"\n\n";
    for(int y=0; y<500; y++)
    {
    encrypted[y] = (ascii[y] * randone * randtwo - (randone - randtwo));
    cout<<encrypted[y];
    }
    int z=0;
    int decrypterone=0;
    int decryptertwo=0;
    cout<<"\n\n";
    cout<<"Please Enter the first number you want to decrypt the above message by - ";
    cin>>decrypterone;
    cout<<"Please Enter the second number you want to decrypt the above message by - ";
    cin>>decryptertwo;
    for(int z=0; z<500; z++)
    {
    ascii[z] = ((encrypted[z] + decrypterone - decryptertwo) * decrypterone * decryptertwo);
    cout<<(char)ascii[z];
    }
    return 0;
    }
    one other thing, whenever I compile this in g++ It gives me an error message when i put down #include <iostream> instead of <iostream.h> but that doesn't happen in KDevelop or any of the windows compilers i've used, why is that?

    Thank you for your help.
    Last edited by Lyuokdea; 08-14-2002 at 10:30 PM.

Popular pages Recent additions subscribe to a feed