pankaj
pankaj

Reputation: 8388

using c code in objective c

Objective C is meant to support C. I have some code in C language and I want to use it in objective C how is that possible? I know it is possible but I am not sure how.

Edit
I want to use following code in objective C. How can I do it?

string FileMeasure="Hello FILE!"
int TempNumOne=FileMeasure.size();
char Filename[100];
for (int a=0;a<=TempNumOne;a++)
{
    Filename[a]=FileMeasure[a];
}

Thanks
Pankaj

Upvotes: 1

Views: 1481

Answers (3)

Shaggy Frog
Shaggy Frog

Reputation: 27601

Objective C is meant to support C.

Not sure what this means. Objective-C is a superset of C.

I have some code in C language and I want to use it in objective C

Just use it. Generally there's no magic required.

Upvotes: 1

ShinTakezou
ShinTakezou

Reputation: 9681

As language, you can consider Objective-C a "super set" of C, so that pure C code works fine when compiled in a Obj-C project; but this is about the language itself, the standard library (it is available in Obj-C as well), and any library with "C linkage". If it makes sense and if it will work or not depends on what exactly the C code does. E.g. if it uses a system-specific library, there could be a porting issue.

Upvotes: 0

Macmade
Macmade

Reputation: 54049

Objective-C is just a kind of layer over C...

If you have C libraries, C code, C functions, or whatever, you'll be able to use them from Objective-C...

Just think about Objective-C as a wrapper for object-oriented C code...

Maybe you'll have to add details, if you want a more specific answer...

Upvotes: 5

Related Questions