Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 A problem about the c++ programming.
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CHINA_yanglei




PostPosted: Tue Mar 17, 2009 4:15 am   Post subject: A problem about the c++ programming.

c++:
#include <iostream.h>
#include <cstdlib.h>
int main()
{
    char ans;
        do
        {
           int fav=rand()%32;
           int num;
           do
           {
              cout<<"Guess my secret number(0-32) ";
                  cin>>num;
                  cout<<(num<fav?"Too Low":num>fav?"Too High":"Right")<<endl;
           }
           while(num!=fav);
        cout<<""Go Again?(y/n)";
                cin>>ans;
        }
    while(ans==y);
        return 0;
}



code:
ERROR:fatal error C1083: Cannot open include file: 'cstdlib.h': No such file or directory

Thank you for solving my question....

[b]Mod Edit: Remember to use syntax and code tags! Thanks Smile
code:
[syntax="cpp"]Code Here[/syntax]
[b]
Sponsor
Sponsor
Sponsor
sponsor
michaelp




PostPosted: Tue Mar 17, 2009 8:25 am   Post subject: RE:A problem about the c++ programming.

Use code tags!
And it should be #include <cstdlib> and #include <iostream>. iostream.h is not standard( I think ) and standard C headers that are used in C++ drop the .h extension, and add a c in front.
Example:
stdio.h
becomes
cstdio.
Tony




PostPosted: Tue Mar 17, 2009 11:43 am   Post subject: RE:A problem about the c++ programming.

@CHINA_yanglei -- don't mix C with C++, and you'll be avoiding many problems.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
CHINA_yanglei




PostPosted: Tue Mar 17, 2009 8:34 pm   Post subject: Re: RE:A problem about the c++ programming.

michaelp @ 17/3/2009 wrote:
Use code tags!
And it should be #include <cstdlib> and #include <iostream>. iostream.h is not standard( I think ) and standard C headers that are used in C++ drop the .h extension, and add a c in front.
Example:
stdio.h
becomes
cstdio.
I also find a error about the "y" which is not appended ' ',and I correct my code just like your advice.The result is satisfied.Thank for your suggestion.Good luck to you!
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: