By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,407 Members | 2,842 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,407 IT Pros & Developers. It's quick & easy.

Need help converting some c++ to c

P: 1
what would i use to replace std::cin.ignore(); from a C++ program to make that section of code work in a C program
Nov 6 '15 #1
Share this Question
Share on Google+
1 Reply

P: 93
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:

Expand|Select|Wrap|Line Numbers
  1. class foo
  2. {
  3.    public:
  4.      int x, y, z;
  5.      int Add(int x, int y, int z);
  6. };
Expand|Select|Wrap|Line Numbers
  1. typedef struct {
  2.  int x; int y; int z;
  3. }foo;
  5. int foo_add(foo* f)
  6. {
  7. ...
  8. }
Nov 6 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.