Author Topic: plz check as CodeBlock syntex  (Read 5678 times)

zu007

  • Guest
plz check as CodeBlock syntex
« on: August 13, 2012, 03:58:47 pm »
plz check as CodeBlock syntex(this program written in turbo c 3.0 syntex)
Code
#include<conio.h>
#include<string.h>
#include<iostream.h>
class String
{
private:
char str[40];

public:
      void menu()
      {
      gotoxy(30,12);
cout<<"Menu";
gotoxy(30,14);
cout<<"1.Comparing Strings";
gotoxy(30,16);
cout<<"2.Add to Strings";

      }
       void getdata()
{
    cin.getline(str,40);
}
int operator ==(String i)
{
if(strlen(str)==strlen(i.str))
       return 1;
       else
       return 0;
}

       void showdata()
       {
       cout<<str;
       }

String operator+(String ob)
      {
    String t;
    strcpy(t.str,str);
   strcat(t.str,ob.str);
    return(t);
      }
};
void main()
{
 String a,b,c;
 char ch;
 clrscr();
a.menu();
 ch=getch();
 clrscr();
 gotoxy(30,12);
 cout<<"Enter first string";
 a.getdata();
 gotoxy(30,14);
 cout<<"Enter second string ";
 b.getdata();
 clrscr();
 switch(ch){
case'1':
       if(a==b)
       {
       gotoxy(30,14);
cout<<"string are equal";
}
else
{
gotoxy(30,14);
cout<<"string are not equal";
}
break;
case'2':
       c=a+b;
       c.showdata();
       break;

 }
getch();
}

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: plz check as CodeBlock syntex
« Reply #1 on: August 13, 2012, 04:04:40 pm »
What is your problem? How can we help you?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: plz check as CodeBlock syntex
« Reply #2 on: August 13, 2012, 05:18:57 pm »
My guess is that he's trying to compile something targeted for the old DOS era Turbo C/C++ compiler from Borland with a newer compiler from another vendor (most likely GCC). That will not work out of the box, and this is not the right place to ask for solutions (it has nothing to do with the IDE).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: plz check as CodeBlock syntex
« Reply #3 on: August 14, 2012, 06:28:31 am »
@zu007:

Please do not post the same question twice in two sections !

I removed the other post.

My guess is that he's trying to compile something targeted for the old DOS era Turbo C/C++ compiler from Borland with a newer compiler from another vendor (most likely GCC). That will not work out of the box, and this is not the right place to ask for solutions (it has nothing to do with the IDE).

Please read the answer carefully.
What Ceniza means, isthat this is not the right forum/website to ask.


When you registered here, you accepted our forum rules:

[...]1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

2. Compiler/Linker errors are NOT Code::Blocks errors. Usually, C++ newcomers tend to confuse the Editor/IDE (Code::Blocks) with the Compiler (MINGW / GCC). You may see some errors in the compiler output because you missed to do something right in your code. But that's not Code::Blocks troubleshooting, that's C++ troubleshooting and does not belong in here. If your program doesn't compile, READ THE C++ MANUAL.

[...]

4. Search before you post. If you've used other IDEs and you're moving to Code::Blocks, try reading the Wiki (e.g. http://wiki.codeblocks.org/index.php?title=FAQ) at the homepage, and if you're confused on how to set up things, SEARCH THE FORUM. Probably the answer you're looking for is in there. Remember, Google is your friend :)

[...]

Finale note: Ignoring these rules may result in the topic being (silently) locked and/or even removed completely without any notice.

[...]

More general help how to use our forum you'll find here, too.

Please respect these rules !


Topic locked, because it violates our forum rules.