0

Hi I am trying to use some pure C library in an iOS app, however I have no clue how to call and pass the parameters. Here are 2 functions, Node is a struct:

Node *parse(FILE *f);
void add_subnode(Node *t, Node *parent);

Can someone show me some sample code how to do it? Or point out to me some good books on this topic.

Thanks Ray

Ray
  • 16,025
  • 5
  • 31
  • 51

1 Answers1

3

You could call C functions like this:

Node *node = parse(f); // node will hold return value

add_subnode(t, parent);
Jack
  • 1,892
  • 1
  • 19
  • 23
  • wow, I feel so stupid. However I have another stupid question, how do I get a file handle? Say I have a tree.txt file in the main bundle, how do I get the C style file handle? – Ray Apr 23 '13 at 02:24
  • FILE *f = fopen("tree.txt", "r"); – Jack Apr 23 '13 at 02:27
  • This should work - `FILE *f = fopen([[[NSBundle mainBundle] pathForResource: @"tree" ofType: @"txt"] UTF8String], "r");` – Jack Apr 23 '13 at 02:33
  • thank you sir, you are my savior. – Ray Apr 23 '13 at 02:36