Even a Working Code in Turbo C++
is not working in Dev++
.. I have Just installed ...... in C: and All Lib /Bin/Dir/Include Paths Are Correct as it was........But still Not working...........
I have Tryed To rebuild it But No use
any Help me out
or Provide me a good C++ compiler ..............

C++ Code:

include<iostream>
#include<stdio>
#include<conio>
int main(void)
{
//clrscr();
int a[10];
int s=3;
int i,j,temp;
cout<<"\t\t *SORTING OF THREE ElEMENTS * ";
for(i=0;i<s;i++)
{
cout<<"Enter the "<<i+1<<" Element: ";
cin>>a;
}
cout<<"\n\nBefore Sorting : \n\n";
for(i=0;i<s;i++)
cout<<a<<" ";
for(i=0;i<s;i++)
for(j=0;j<(s-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\n\nAfter Sorting : \n\n";
for(i=0;i<s;i++)
{
cout<<a<<" ";
}
getch();
}

Just see
for a Basci prog
it shows error.......

PGM;

#include <iostream>
#include<conio>
int main()
{
cout<<"HELLO" <<end;
return 0;
}

ERROR

Compiler: Default compiler
Executing g++.exe...
g++.exe "D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp" -o "D:\Documents and Settings\PRASANNA.GSP\Desktop\G.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -I"C:\Dev-Cpp\lib" -L"C:\Dev-Cpp\lib"
D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp:2:16: conio: No such file or directory
D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp: In function `int main()':
D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp:6: error: `cout' undeclared (first use this function)
D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
D:\Documents and Settings\PRASANNA.GSP\Desktop\G.cpp:6: error: `end' undeclared (first use this function)

Execution terminated

Plz help me out

It would likely help if you included using statements before main...

try #include <conio.h> however if it still doesn't work with the below code, just get rid of it for now & take 1 problem at a time.

#include <iostream>
int main()
{
std::cout << "HELLO" << std::endl;
std::cin.get();
return 0;
}

Try that... Or (to get rid of those std:: parts (alternatively instead of each using statement you can use just "using namespace std;" instead without the "))

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
cout << "HELLO" << endl;
cin.get();
return 0;
}

Note there is also no such thing as this #include<stdio>
it should be csdtio....
but you can ditch that if you change getch() to cin.get()

Please don't blame a compiler/IDE for your mistakes.

By the way Dev-Cpp is dead IDE. It's advised you swap to Visual C++ (express 2008 its free) or Code::Blocks

Chris

Oh Ho Now I got it
why ...........
Since i was using only TURBO C++ old Blue screen..........
i do it only with #include<conio.h>
for getch()
cout; etc
But
Now i got it
Boz
When using Visual C++ to write/compile with "std::" at the beginning..so why is that? ha ha lol

okay Thanks Any way
I have learned a lession From u guys
Thanks to

jbennet

Freaky_Chris

and

Yiuca

Long story short, because standards have changed since the days of Turbo C++ and also the compiler also does some work automatically for you sometimes.

(btw if the thread is solved don't forget to mark it as solved)

Chris

Help
it compiled with no error
but when i run these code it doesnt show any result
( ie when we use getch().....it shows the result know)
that part is missing
its not showsing the result

heres the code

#include<iostream>
#include<cstdio>
//#include<conio>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
//clrscr();
int a[10];
int s=3;
int i,j,temp;
cout<<"\t\t *SORTING OF THREE ElEMENTS * "<<endl<<endl;
for(i=0;i<s;i++)
{
cout<<"Enter the "<<i+1<<" Element: ";
cin>>a;
}
cout<<"\n\nBefore Sorting : \n\n";
for(i=0;i<s;i++)
cout<<a<<" ";
for(i=0;i<s;i++)
for(j=0;j<(s-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\n\nAfter Sorting : \n\n";
for(i=0;i<s;i++)
{
cout<<a<<" ";
}
return 1;
}

and use cin.get();

to pause so you can see the result

use return 0;

Chris

Please use code tags to post indented code.

#include<iostream>
#include<cstdio>
//#include<conio>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
    //clrscr();
    int a[10];
    int s=3;
    int i,j,temp;
    cout<<"\t\t *SORTING OF THREE ElEMENTS * "<<endl<<endl;
    for(i=0;i<s;i++)
    {
        cout<<"Enter the "<<i+1<<" Element: ";
        cin>>a[i];
    }
    cout<<"\n\nBefore Sorting : \n\n";
    for(i=0;i<s;i++)
    cout<<a[i]<<" ";
    for(i=0;i<s;i++)
    for(j=0;j<(s-i);j++)
    if(a[j]>a[j+1])
    {
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
    }
    cout<<"\n\nAfter Sorting : \n\n";
    for(i=0;i<s;i++)
    {
        cout<<a[i]<<" ";
    }
    return 1;
}

os ya i used


cout<<a<<" ";
}
cin.get();
return 0;
}

But Not Working
and i figured it out

its

cout<<a<<" ";
}
system("PAUSE");
return 0;
}

Thanks Chris SiR........

system("pause");
is not really adviseable.
cin.get() is doing it's job just fine... unfortunately it's all a little complex. There is a sticky at the top of the C++ forum Called "How do i flush the input buffer"...it may all seem a little confusing but never the less it's worth the read.

One quick solution is cin.get(); cin.get(); just call it twice you can also go down the line of cin.ignore() and many other methods all discused in that the thread>

Chris

#include<iostream>
#include<cstdio>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
//clrscr();
int a[10];
int s=3;
int i,j,temp;
cout<<"\t\t *SORTING OF THREE ElEMENTS * "<<endl<<endl;
for(i=0;i<s;i++)
{
cout<<"Enter the "<<i+1<<" Element: ";
cin>>a[i];
}
cout<<"\n\nBefore Sorting : \n\n";
for(i=0;i<s;i++)
cout<<a[i]<<" ";
for(i=0;i<s;i++)
for(j=0;j<(s-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\n\nAfter Sorting  : \n\n";
for(i=0;i<s;i++)
{
cout<<a[i]<<" ";
}
//system ("pause");
cin.get();
cin.get();
return 0;

}

Oh Great Chris............
It Works .........
I have one question for you.........

Why WE use cin.get(); TWICE

I saw the Thread......... you have mentioned
its So Complicated
its not Understandale .......
so
can you plese say
it in simple words
plz chris..........

simplest method is to do something like this

cin.ignore ( 80, '\n' );
cin.get()

The reason cin.get() appear to be skipped is that it reads one character from the input stream.

After calling cin >> you find that at least the '\n' character is left in the inputstream. Thus cin.get() will read this as requested which then leaves you a clean inputstream. In this case calling cin.get() again solves the problem.

Chris

Okay
Thanks 4 the valuable infomation CHRIS .............
and
this Make me a Lesson for Today.......
thnks once again
for teachinig me this fact


Thanks CHRIS

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.