total noob- call c function from c#

A

Adam Chapman

Hi,

Im going through a steep learnig curve trying to learn to program in
C, i'm used to the far simpler matlab.

I was thinking about user interfaces, and from what i've seen it looks
like c# is the best language to use for that. Is it possible to run C
scripts from c#?

Take, for example, a C# application which showed a webcam output, and
a C function was used to filter some colours on that webcam.

Could you implement the colour filtering in C and show the result in
the C# app, or would you have to re-write everything in C#?

Thanks for any advice, Im not really looking in any depth at the
moment, just trying to find out if it's possible and to what degree of
awkwardness.

Adam
 
C

CBFalconer

Adam said:
.... snip ...

Could you implement the colour filtering in C and show the result
in the C# app, or would you have to re-write everything in C#?

For C# you probably need some Microsoft groups. That is a
Microsoft language, and has nothing to do with C.
 
L

Lassie

CBFalconer said:
For C# you probably need some Microsoft groups. That is a
Microsoft language, and has nothing to do with C.

By this logic the answer in the MS group might just as well be

"For C you probably need a C group. That is a non
Microsoft language, and has nothing to do with C#."
 
L

Lassie

Adam Chapman said:
Hi,

Im going through a steep learnig curve trying to learn to program in
C, i'm used to the far simpler matlab.

I was thinking about user interfaces, and from what i've seen it looks
like c# is the best language to use for that. Is it possible to run C
scripts from c#?

Take, for example, a C# application which showed a webcam output, and
a C function was used to filter some colours on that webcam.

Could you implement the colour filtering in C and show the result in
the C# app, or would you have to re-write everything in C#?

Thanks for any advice, Im not really looking in any depth at the
moment, just trying to find out if it's possible and to what degree of
awkwardness.

This is possible but you should only be doing that after learning the basics
of a language.

You dont have to use C for your problem you can do everything in C#. That
would be a far easier and more productive route. However, if you have C#
questions in the future this is not the group for that
 
K

Keith Thompson

Lassie said:
By this logic the answer in the MS group might just as well be

"For C you probably need a C group. That is a non
Microsoft language, and has nothing to do with C#."

Not necessarily. C defines no mechanisms for calling C code from C#.
C# might define such mechanisms. If it does, then the question will
get better answers in a C# forum.
 
T

Tomás Ó hÉilidhe

Im going through a steep learnig curve trying to learn to program in
C, i'm used to the far simpler matlab.


A common misconception. Other programming languages seem easier
because they have a bellboy greeting you at the door telling you about
all the wonderful library functions the language has. You might be
able to do something in Matlab with one line of code, something that
would take thousands of lines of C code...

....unless of course you get a C library for doing what you want, in
which case you can get it done with one line in C too. Libraries for C
aren't as publicised as the built-in libraries for other languages...
but they're out there... they're everywhere.

Here's a few of my favourites:
* ncurses for managing a terminal
* wxWidgets for a program that has a dialogue box with buttons
* GMP for doing big number calculations (you won't find better or
faster in any language)

Some of them are fully-portable, i.e. they'll run as intended on any
implementation of the C Standard, and some of them depend on stuff
like the existence of a keyboard. If you're writing a GUI application
with a dialogue box though, it's not a hard blow to take to assume
that there's a keyboard.
 
K

Kenny McCormack

By this logic the answer in the MS group might just as well be

"For C you probably need a C group. That is a non
Microsoft language, and has nothing to do with C#."

There's two possible responses to that analogy.

The first is that, yes, this newsgroup (comp.lang.c) is the way it is
because of the people who rule it - i.e., the regs. This level of anal
specificity is not found anywhere else. Other groups are more likely to
be willing to discuss what you want to discuss - or kindly just look the
other way, something they never do here.

The second is that, yes, the problem you identify is real. The problem
with newsgroups being obsessed (to one degree or another) with this sort
of specificity is that some (perfectly reasonable) problems end up
falling in neither camp - rejected by both.

The classic example of this that always comes to my mind is that of the
"Cygwin" software suite. Every so often, somebody posts a "shell-ish"
question to comp.unix.shell, that seems confused in some way, and it
eventually comes to light that they are using the Cygwin port of bash,
which, despite all best efforts, just isn't the same as bash running under
Unix. So, when people ask their Cygwin-bash questions in
comp.unix.shell, and it comes to light that they are actually using
"not-Unix", they get told to go stick it (in word similar to, thought
not anywhere near as vicious, as those used here). But, and this is the
important thing, it's not like there is a newsgroup that is about bash
programming under Cygwin. The Windows newsgroups are all about WIMPs
(Windows, Icons, Mice, and Pictures) and aren't really comprende on
shell things. So, the hapless questioner is left out in the cold.

Note, incidentally, that I'm not saying that there aren't resources for
this (I'm sure some helpful person is going to come along any minute and
tell me about mailing lists and stuff at Cygwin and Redhat and
whatever), but (as you can see), that doesn't cut any ice with me. You
shouldn't have to go to substandard things like mailing lists and web
fora and so on, when newsgroups should be able to handle your case.
 
K

Kenny McCormack

Lassie said:
This is possible but you should only be doing that after learning the basics
of a language.

You dont have to use C for your problem you can do everything in C#. That
would be a far easier and more productive route. However, if you have C#
questions in the future this is not the group for that

The implication is that he would like to do the low-level, compute-heavy
stuff in a language suitable for low-level, compute-heavy stuff, which
C# isn't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top