Need help converting some c++ to c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aceash100
    New Member
    • Nov 2015
    • 1

    #1

    Need help converting some c++ to c

    what would i use to replace std::cin.ignore (); from a C++ program to make that section of code work in a C program
  • kiseitai2
    New Member
    • Jul 2007
    • 93

    #2
    Read this link and build a function in C that implements the functionality described in the page. Do the same for any other c++ std methods. Remember that c is much simpler than c++ so all you need to do in general is to convert class-like structures into c structures and corresponding functions. Basically, sit down and start reading the c++ standard documentation. If you can't find the equivalent function in the C standard, you will have to understand what the method in a class or the c++ function does and emulate that with your own functions.

    Code example:
    C++

    Code:
    class foo
    {
       public:
         int x, y, z;
         int Add(int x, int y, int z);
    };
    C
    Code:
    typedef struct {
     int x; int y; int z;
    }foo;
    
    int foo_add(foo* f)
    {
    ...
    }


    Comment

    Working...