Like Tree4Likes
  • 4 Post By Salem

C++ to C

This is a discussion on C++ to C within the C Programming forums, part of the General Programming Boards category; I have a code written in C++ and I need to convert it to C. I don't have as much ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    1

    C++ to C

    I have a code written in C++ and I need to convert it to C. I don't have as much experience in C, can anyone give me a hand in the conversion?

    Code:
    #include <iostream>
     using namespace std;
     int main()
     {int m,d,y;
     cout<<"Enter month: ";
     cin>>m;
     cout<<"Enter day: ";
     cin>>d;
     cout<<"Enter year: ";
     cin>>y;
     cout<<"The day after "<<m<<"/"<<d<<"/"<<y<<" is: ";
     d++;
     if(d>30)
        {d=1;
        m++;
        if(m>12)
             {m=1;
             y++;
             }
       }
     cout<<m<<"/"<<d<<"/"<<y<<endl;
     system("pause");
     return 0;
     }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,618
    I suggest that you learn about C I/O available via <stdio.h>.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    33,292
    > I have a code written in C++
    I can haz a serch enjun

    You found your homework on another forum, and now you want help turning it into the right programming language.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21