Thread: hihi ... very sad ..... cannot run propertly my program... help me !!!

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    Red face hihi ... very sad ..... cannot run propertly my program... help me !!!

    help me see my program.... cannot run propertly.............
    <code>
    #include<iostream.h>
    #include<ctype.h>
    #include<fstream.h>
    #include<string.h>
    #include<iomanip.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<windows.h>
    #include<stdio.h>
    #include <time.h>

    class String
    {
    int size;
    int len;
    char *codetable;
    char text[200];
    char *enc;
    char *dec;


    public:

    String(char *b)
    {
    len=strlen(b)+1;
    codetable=new char[len];
    strcpy(codetable,b);
    }
    void setstring(char *c);
    void encode(void);
    void menu(void);
    void decode(void);

    };

    void String::setstring(char *c)
    {
    len=strlen(c)+1;
    codetable=new char[len];
    strcpy(codetable,c);
    }

    void String::encode(void)
    {
    system("cls");
    int x,y;
    char ans;
    //char name[20];
    cout<<"\n\n\nPlease Enter The Message:"<<endl;
    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
    cin.ignore();
    cin.getline(text,200);
    size=strlen(text);
    enc=new char[size+1];
    enc[size]='\0';
    for(x=0;x<size;x++)
    {
    for(y=0;y<len;y=y+1)
    {
    if(text[x]==codetable[y])
    {
    enc[x]=codetable[y+1];
    }
    }
    }


    cout<<"\n\n\n\nThe Message After Encode:"<<endl;
    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
    cout<<enc<<endl;
    cout<<"\n\n\nPress one character to continue: ";
    cin>>ans;
    /*cout<<"\n\n\n\nEnter file name(a:file name.dat):";
    cin.getline(name,20);
    ofstream sfile;
    sfile.open(name);
    sfile<<enc;
    sfile.close();
    system("cls");*/
    menu();
    }


    void String::menu()
    {


    char choice='X',*dateString;

    do
    {
    time_t currentTime;
    currentTime = time(NULL);
    dateString = ctime(&currentTime);
    system("CLS");
    cout <<"\n\n\n\t\t\t [Encode Menu]\n";
    cout <<"\n\t\t\t Today is ";
    //displays todays date from time string;
    for (int i=0;i<10;i++)cout <<dateString[i];
    cout <<" ";
    for (i=20;i<24;i++)cout <<dateString[i];

    cout <<"\n\n\t\t ";
    cout <<"\n\t\t [1] Encode String ";
    cout <<"\n\t\t ";
    cout <<"\n\t\t [2] Decode String ";
    cout <<"\n\t\t ";
    cout <<"\n\t\t [3] Translation Table ";
    cout <<"\n\t\t ";
    cout <<"\n\t\t [4] Exit ";
    cout <<"\n\t\t ";
    cout <<"\n\n\n\n\n\t\t Type in a selection from [1] to [4]: ";
    cin >>(choice);

    switch (choice)
    {
    case '1':encode();
    break;

    case '2':decode();
    break;

    case '3'://editData();
    break;

    case '4':system("cls"); cout <<"\n\t Exiting program......";
    break;

    default: system("CLS");cout << "Invalid Selection";
    }

    }while (choice != '4');
    }

    void String::decode(void)
    {
    int x,y;
    char ans;
    system("cls");
    cout<<"\n\n\nThe Message Before Decode: "<<endl;
    cout<<"~~~~~~~~~~~~~~~~~~~~"<<endl;
    cout<<enc<<endl;
    dec=new char[size+1];
    dec[size]='\0';
    for (x=0;x<size;x++)
    {
    for (y=0;y<len;y++)
    {
    if(enc[x]==codetable[y])
    dec[x]=codetable[y-1];
    }
    }
    cout<<"\n\n\n\nThe Message After Decode:"<<endl;
    cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
    cout<<dec<<endl;
    cout<<"\n\n\n\n\nPress one character to continue: ";
    cin>>ans;
    }
    void main()
    {


    String table("qazwsxedcrfvtgbyhnujmikolpOPLIKUJMYHNTGBRFV EDCWSXQAZ1!2@3#4$5%6^7&8*9(0)-_=+,.< >?:;'{}[]|/È");

    String table("");
    table.setstring(adidas);
    table.menu();
    }
    </code>

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    What is it not doing properly? Are you getting errors at compile/link time or are you getting errors at run-time? If so, what do the specific errors say?

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Code:
    #include<iostream.h>
    #include<ctype.h>
    #include<fstream.h>
    #include<string.h>
    #include<iomanip.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<windows.h>
    #include<stdio.h>
    #include <time.h>
    Why do you have so many included headers! No! You don't need not even half of them. Take the ones you don't use out. Not only do they take extra time to compile but they take up loads of space in your executable and may even run your program slower.
    Code:
    void main()
    NO WAY. Use int main() if you're curious why, read the FAQ (which you should be doing anyways).

    BTW, code tags are with square brackets, not < > signs. So it'll be [ code ] dsfjk [ /code ] (without the spaces).

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    Hmmmmm is it popular to use names like 'help me' or 'cannot run my program' ?

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Hmmmmm is it popular to use names like 'help me' or 'cannot run my program' ?
    No, definately not. At least it shouldn't be that is, it's damn annoying.

    A few links for the OP to read:
    http://cboard.cprogramming.com/annou...p?s=&forumid=3
    http://cboard.cprogramming.com/showt...threadid=13473
    http://faq.cprogramming.com/
    http://www.catb.org/~esr/faqs/smart-questions.html
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    What compiler are you using out of curiousity? See if your compiler supports standard C++ headers (ctime, iostream, cstdlib, etc...).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  3. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  4. Replies: 3
    Last Post: 07-11-2005, 03:07 AM
  5. plz help me run this program!!!
    By galmca in forum C Programming
    Replies: 8
    Last Post: 02-01-2005, 01:00 PM