f



Convert string to C expression syntax

Hi,
I want to do the following,

==========================================
int main(int argc, char *argv[])
{

    ...
    ...
    if (*argv[1]) 
    {
      ...
    }

    ...
}
==========================================

as i tried to show above, I want to pass a filter condition
at command-line input. And I want to convert that input string
to 'if-condition expression' so that it can be used in the program.
How can it be done?? I am struggling very hard to get it right.

Thank you.
-- Nilay
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
nilay
7/31/2013 2:58:38 AM
comp.lang.c.moderated 1019 articles. 0 followers. Post Follow

13 Replies
419 Views

Similar Articles

[PageSpeed] 0

On 07/30/2013 10:58 PM, nilay wrote:
> Hi,
> I want to do the following,
> 
> ==========================================
> int main(int argc, char *argv[])
> {
> 
>     ...
>     ...
>     if (*argv[1]) 
>     {
>       ...
>     }
> 
>     ...
> }
> ==========================================
> 
> as i tried to show above, ...

It's a very bad idea to ask how to write code that does something, and
then to explain what you want the code to do by writing code. If you
don't know how to write such code, the code you do write will probably
do something entirely different from what you want to do. You've
provided an excellent example of this.

The code above takes the second element of argv (without first checking
to determine whether there IS a second element - which means your code
has undefined behavior if it is invoked with no arguments), and checks
whether or not the first char of that string is '\0'. That has almost
nothing to do with your stated goal:

> ... I want to pass a filter condition
> at command-line input. And I want to convert that input string
> to 'if-condition expression' so that it can be used in the program.
> How can it be done?? I am struggling very hard to get it right.

All command line inputs are text strings. If those strings describe
filter conditions, you're going to have to decide what kinds of filter
conditions you want to support, and then define a syntax for specifying
those conditions on the command line. Then you'll have to write code
that reads the command line arguments, parsing them according to the
grammar you've specified, and converting them into some internal
representation. Then write code that uses the internal representation to
implement the filter.
That probably sounds to you like an excessively vague,
nearly-meaningless string of jargon, and there's a reason for that.
Until you've specified what kinds of filter conditions you want your
program to support, it's hard to say anything more specific than that
about how to do it.
-- 
James Kuyper
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
James
8/1/2013 2:22:41 AM
On Tue, 30 Jul 2013 21:58:38 -0500 (CDT), nilay <nilaybhatt@gmail.com>
wrote:

>Hi,
>I want to do the following,
>
>==========================================
>int main(int argc, char *argv[])
>{
>    ...
>    if (*argv[1]) 
>    {
>      ...
>    }
>    ...
>}
>==========================================
>
>as i tried to show above, I want to pass a filter condition
>at command-line input. And I want to convert that input string
>to 'if-condition expression' so that it can be used in the program.
>How can it be done?? I am struggling very hard to get it right.

It depends on what type of condition you want to check for.

If you want to check if the string exists, you would actually check
argc.  C does not support omitted command line arguments except at the
end.

If you want to check for an empty string (and your system allows you
to specify one as a command line argument), then the code you posted
will check that.  An empty string is an array of 1 char and that char
has the value '\0'.  Your code evaluates the first char in the array
pointed to by argv[1].

If you want to check whether the string has a certain value, you would
use strcmp or strncmp in the condition of your if statement. Something
along the lines of 
     if (!strcmp(argv[1], "ABC")
          {/* equal code */}
     else
          {/* optional not equal code */}

-- 
Remove del for email
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Barry
8/1/2013 2:22:44 AM
nilay <nilaybhatt@gmail.com> wrote:
> Hi,
> I want to do the following,
> 
> ==========================================
> int main(int argc, char *argv[])
> {
> 
>    ...
>    ...
>    if (*argv[1]) 
>    {
>      ...
>    }
> 
>    ...
> }
> ==========================================

You need to check if argv[1] is NULL before trying to use any
character string it might point to.

> as i tried to show above, I want to pass a filter condition
> at command-line input. And I want to convert that input string
> to 'if-condition expression' so that it can be used in the program.

There is no way to convert a string to C code at runtime in Standard
C.  The only implementations likely to have that as an extension
are C interpreters.  And you'll need to deal with problems like
the expression being invalid C.

You may write code to parse the filter expression yourself.  Some
C texts have an exercise to write a 4-function calculator program
- this is a basic start to evaluating exprssions.  There are also
tools such as yacc, bison, lex, and flex for writing complex parsers
such as those found in compilers, which generate C.  These expect you
to compile the code in advance.

A program called tcpdump does filter-matching, but its filter
expressions are for matching network packets.

If you are interested in pattern-matching STRINGS there are a number
of packages like pcre that take a pattern in a particular format and
a string and see if there is a match.


> How can it be done?? I am struggling very hard to get it right.

Another possibility is to take the filter-expression, put a C program
around it, invoke a compiler, and then use dynamic linking to 
call the function.  This isn't standard C either.


What are you planning on using as filter expressions?  What are they
filtering?
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
gordonb
8/1/2013 2:22:47 AM
Barry Schwarz <schwarzb@dqel.com> writes:
[...]
> If you want to check whether the string has a certain value, you would
> use strcmp or strncmp in the condition of your if statement. Something
> along the lines of 
>      if (!strcmp(argv[1], "ABC")
>           {/* equal code */}
>      else
>           {/* optional not equal code */}

To be clear (since the OP may not be aware of it), strcmp() returns a
value less than, equal to, or greater than 0 if the first argument is
respectively than, equal to, or greater than the right argument.

So (!strcmp(argv[1], "ABC") is true if the string pointed to by argv[1]
is equal to "ABC".  If you treat the result of strcmp() as a boolean,
it's true of the strings are unequal, false if they're equal.

Personally, I prefer to be more explicit; I'd write:

    if (strcmp(argv[1], "ABC") != 0) ...

but you'll commonly see the !strcmp() form in C code.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Keith
8/1/2013 5:58:21 PM
On 2013-08-01, Keith Thompson <kst-u@mib.org> wrote:
> Barry Schwarz <schwarzb@dqel.com> writes:
> [...]
>> If you want to check whether the string has a certain value, you would
>> use strcmp or strncmp in the condition of your if statement. Something
>> along the lines of 
>>      if (!strcmp(argv[1], "ABC")
>>           {/* equal code */}
>>      else
>>           {/* optional not equal code */}
>
> To be clear (since the OP may not be aware of it), strcmp() returns a
> value less than, equal to, or greater than 0 if the first argument is
> respectively than, equal to, or greater than the right argument.
>
> So (!strcmp(argv[1], "ABC") is true if the string pointed to by argv[1]
> is equal to "ABC".  If you treat the result of strcmp() as a boolean,
> it's true of the strings are unequal, false if they're equal.
>
> Personally, I prefer to be more explicit; I'd write:
>
>     if (strcmp(argv[1], "ABC") != 0) ...
>
> but you'll commonly see the !strcmp() form in C code.

Your preferred code does the opposite of the original code.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Ike
8/2/2013 2:05:25 AM
Ike Naar <ike@ukato.freeshell.org> writes:
> On 2013-08-01, Keith Thompson <kst-u@mib.org> wrote:
>> Barry Schwarz <schwarzb@dqel.com> writes:
>> [...]
>>> If you want to check whether the string has a certain value, you would
>>> use strcmp or strncmp in the condition of your if statement. Something
>>> along the lines of 
>>>      if (!strcmp(argv[1], "ABC")
>>>           {/* equal code */}
>>>      else
>>>           {/* optional not equal code */}
>>
>> To be clear (since the OP may not be aware of it), strcmp() returns a
>> value less than, equal to, or greater than 0 if the first argument is
>> respectively than, equal to, or greater than the right argument.
>>
>> So (!strcmp(argv[1], "ABC") is true if the string pointed to by argv[1]
>> is equal to "ABC".  If you treat the result of strcmp() as a boolean,
>> it's true of the strings are unequal, false if they're equal.
>>
>> Personally, I prefer to be more explicit; I'd write:
>>
>>     if (strcmp(argv[1], "ABC") != 0) ...
>>
>> but you'll commonly see the !strcmp() form in C code.
>
> Your preferred code does the opposite of the original code.

D'oh!

I'm tempted to say that this demonstrates the dangerous obscurity
of the !strcmp() form, so that even experienced programmers can get
it wrong, but I'll resist that temptation and just try to pay more
attention next time.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Keith
8/2/2013 11:34:04 PM
nilay  wrote:
>as i tried to show above, I want to pass a filter condition
>at command-line input. And I want to convert that input string
>to 'if-condition expression' so that it can be used in the program.
>How can it be done?? 

This may or not be of help for what you need, (as others replied, the
requirements are vague), but you may want to look at the source code
of the "find" command. (In Unix/Linux/FreeBSD etc.)

To see how a list of switches in the command line, such as

    find / -type f \( -mtime < 3 -o -size > 10k \)  \( -name AB -o
-name BA \) ...

is converted in conditions that can be checked at run time.

In the general case, you need to build an interpreter for a small
embedded language, specific to the conditions you need to check.
--
Roberto Waltman

[ Please reply to the group,
  return address is invalid ]
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Roberto
8/5/2013 4:24:07 PM
On Wednesday, July 31, 2013 3:58:38 AM UTC+1, nilay wrote:
>  
> I want to do the following,
> 
> as i tried to show above, I want to pass a filter condition
> at command-line input. And I want to convert that input string
> to 'if-condition expression' so that it can be used in the program.
> 
> How can it be done?? I am struggling very hard to get it right.
> 
C is compiled, so none of the compile time logic is avialable at
runtime. Unlike some other languages you can't write a string in
C like "if(a==b) printf("Hi");" and have the C environment evaluate
it for you.
You can write your own interpreter. Go to my website
http://www.malcolmmclean.site11.com/www
and look at the MiniBasic webpages (below the book) to understand how 
to get started in the interpreter game.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
malcolm
9/2/2013 9:09:12 AM
 > On 7/30/2013 7:58 PM, nilay wrote:
 >
> I want to do the following,
>
> ==========================================
> int main(int argc, char *argv[])
> {
>
>      ...
>      ...
>      if (*argv[1])
>      {
>        ...
>      }
>
>      ...
> }
> ==========================================
>
> as i tried to show above, I want to pass a filter condition
> at command-line input. And I want to convert that input string
> to 'if-condition expression' so that it can be used in the program.
> How can it be done?? I am struggling very hard to get it right.

You can't do this in C. If you want to do stuff like this, you should 
take up Python instead.

-- 

Ciao,           Paul D. DeRocco
Paul            mailto:pderocco@ix.netcom.com
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Paul
9/7/2013 4:25:49 AM
On 09/07/2013 12:25 AM, Paul D. DeRocco wrote:
>  > On 7/30/2013 7:58 PM, nilay wrote:
>  >
>> I want to do the following,
>>
>> ==========================================
>> int main(int argc, char *argv[])
>> {
>>
>>      ...
>>      ...
>>      if (*argv[1])
>>      {
>>        ...
>>      }
>>
>>      ...
>> }
>> ==========================================
>>
>> as i tried to show above, I want to pass a filter condition
>> at command-line input. And I want to convert that input string
>> to 'if-condition expression' so that it can be used in the program.
>> How can it be done?? I am struggling very hard to get it right.
> 
> You can't do this in C. If you want to do stuff like this, you should 
> take up Python instead.

You can't do this that way in C, nor in any other simple way. It might
be simpler to do it in Python, but it certainly can be done in C. You
just need to write code for parsing the condition expression, and then
evaluating it. If the condition expression has a very simple syntax,
that's trivial to do. However, even if he wants to support the full
complexity of a C-like syntax, it should still be feasible. Components
(or at least, design ideas) borrowed from a C compiler should be
adaptable to this use. C has famously been a bootstrapped language: more
advanced versions of C were first implemented by using more primitive
versions of C to write the compiler, so such components can certain be
written in C.
-- 
James Kuyper
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
James
9/11/2013 10:27:27 PM
On Wednesday, July 31, 2013 8:28:38 AM UTC+5:30, nilay wrote:
> Hi,
> 
> I want to do the following,
> 
> 
> 
> ==========================================
> 
> int main(int argc, char *argv[])
> 
> {
> 
> 
> 
>     ...
> 
>     ...
> 
>     if (*argv[1]) 
> 
>     {
> 
>       ...
> 
>     }
> 
> 
> 
>     ...
> 
> }
> 
> ==========================================
> 
> 
> 
> as i tried to show above, I want to pass a filter condition
> 
> at command-line input. And I want to convert that input string
> 
> to 'if-condition expression' so that it can be used in the program.
> 
> How can it be done?? I am struggling very hard to get it right.
> 
> 
> 
> Thank you.
> 
> -- Nilay
> 
> -- 
> 
> comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
> 
> have an appropriate newsgroups line in your header for your mail to be seen,
> 
> or the newsgroup name in square brackets in the subject line.  Sorry.

You should use switch case here - if argument is NUMERIC, If its a string then you can look for if else go with strncmp/memcmp.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Nitin
9/11/2013 10:31:28 PM
 > On 9/11/2013 3:27 PM, James Kuyper wrote:
>> On 09/07/2013 12:25 AM, Paul D. DeRocco wrote:
>>
>> You can't do this in C. If you want to do stuff like this, you should
>> take up Python instead.
>
> You can't do this that way in C, nor in any other simple way. It might
> be simpler to do it in Python, but it certainly can be done in C. You
> just need to write code for parsing the condition expression, and then
> evaluating it. If the condition expression has a very simple syntax,
> that's trivial to do. However, even if he wants to support the full
> complexity of a C-like syntax, it should still be feasible. Components
> (or at least, design ideas) borrowed from a C compiler should be
> adaptable to this use. C has famously been a bootstrapped language: more
> advanced versions of C were first implemented by using more primitive
> versions of C to write the compiler, so such components can certain be
> written in C.

Well, sure, you can do anything in any language. But you can't do it in 
the simple way that the OP seemed to want. I interpret the question as 
how to evaluate an expression supplied at runtime, in the same context 
as the expressions that are part of the program. Perhaps that wasn't 
what was meant--the question wasn't entirely clear.

-- 

Ciao,           Paul D. DeRocco
Paul            mailto:pderocco@ix.netcom.com
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Paul
9/12/2013 4:34:29 PM
On 11/09/2013 23:27, James Kuyper wrote:
> On 09/07/2013 12:25 AM, Paul D. DeRocco wrote:
>>   > On 7/30/2013 7:58 PM, nilay wrote:
>>   >
>>> I want to do the following,
>>>
>>> ==========================================
>>> int main(int argc, char *argv[])
>>> {
>>>
>>>       ...
>>>       ...
>>>       if (*argv[1])
>>>       {
>>>         ...
>>>       }
>>>
>>>       ...
>>> }
>>> ==========================================
>>>
>>> as i tried to show above, I want to pass a filter condition
>>> at command-line input. And I want to convert that input string
>>> to 'if-condition expression' so that it can be used in the program.
>>> How can it be done?? I am struggling very hard to get it right.
>>
>> You can't do this in C. If you want to do stuff like this, you should
>> take up Python instead.
>
> You can't do this that way in C, nor in any other simple way. It might
> be simpler to do it in Python, but it certainly can be done in C. You
> just need to write code for parsing the condition expression, and then
> evaluating it. If the condition expression has a very simple syntax,
> that's trivial to do. However, even if he wants to support the full
> complexity of a C-like syntax, it should still be feasible. Components
> (or at least, design ideas) borrowed from a C compiler should be
> adaptable to this use. C has famously been a bootstrapped language: more
> advanced versions of C were first implemented by using more primitive
> versions of C to write the compiler, so such components can certain be
> written in C.

Yes and if you are running C on an interpreter (they do exist) it comes 
about pretty naturally.

Francis
>
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Francis
9/12/2013 4:38:57 PM
Reply:

Similar Artilces:

C++ And TDD/ C++ programming on Android/ String Calculator Kata in C++/ C++and OpenGL on Android with the NDK/c++ Convert Integers to Roman Numerals
C++and OpenGL on Android with the NDK Ian presents how to use the Android NDK to program in C++ with STL. The pre= sentation was given about a week before NDK-r5 came out so the parts about = using a modified tool-chain are outdated DOWNLOAD http://hitfile.net/aL1K=20 C++ programming on Android Android is a Java-centric mobile operating system built on top of Linux. Fo= r those times when the Android API doesn't do what you want, or doesn't do = it fast enough, you can always get down-and-dirty with C/C++. The author di= scusses the hows and whys of so-called "nat...

C++ And TDD/ C++ programming on Android/ String Calculator Kata in C++/ C++and OpenGL on Android with the NDK/c++ Convert Integers to Roman Numerals
- C++and OpenGL on Android with the NDK Ian presents how to use the Android NDK to program in C++ with STL. The pre= sentation was given about a week before NDK-r5 came out so the parts about = using a modified tool-chain are outdated DOWNLOAD http://hitfile.net/aL1K=20 -C++ programming on Android Android is a Java-centric mobile operating system built on top of Linux. Fo= r those times when the Android API doesn't do what you want, or doesn't do = it fast enough, you can always get down-and-dirty with C/C++. The author di= scusses the hows and whys of so-called &qu...

C++ And TDD/ C++ programming on Android/ String Calculator Kata in C++/ C++and OpenGL on Android with the NDK/c++ Convert Integers to Roman Numerals #2
- C++and OpenGL on Android with the NDK Ian presents how to use the Android NDK to program in C++ with STL. The presentation was given about a week before NDK-r5 came out so the parts about using a modified tool-chain are outdated DOWNLOAD http://hitfile.net/aL1K -C++ programming on Android Android is a Java-centric mobile operating system built on top of Linux. For those times when the Android API doesn't do what you want, or doesn't do it fast enough, you can always get down-and-dirty with C/ C++. The author discusses the hows and whys of so-called "native&quo...

convert c# code to c++/c
hi people, Im stuck with a problem. I want to convert the following C# code to c++/c im trying to convert it line by line by myself. but still cant do away with some errors.. kindly help here is my code.. Imports System.Net Imports System.Net.Sockets Imports System.IO Public Class Form1 Private Client As New UdpClient(4370) 'Local machine uses UDP and port 4370 Private ZkDevice As New IPEndPoint(IPAddress.Parse("192.168.1.201"), 4370) 'Address of Device and port Private SessionID As UInt16 'ID of session. Each session have a unique ID ...

jython and C-c C-c
How do I get C-c C-c to work with jython? I have the jpython command set to jython, and I can start the interpreter with C-C ! and then use C-c C-c, but this is rather frustrating. If I try to use C-c C-c without first starting the interpreter in another window I get wrong type argument: sequencep, jpython Thanks, Dave Cook ...

Better C/C++ Than C/C++?
I am looking for a good systems programming language that can be used instead of C/C++. My qualifications for the language are: * mature compiler(s) that produce native-code binaries (for Windows) * open source - preferable, but not 100% necessary Thanks, Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) Ocaml, D, cyclone, Eiffel, Beta >...

C++ implementation for C API ---- converting legacy C code to C++
[My apologies if this LONG posting is off-topic] In this day and age, you never say no to any work that is thrown at you ---- so when I was offered this short-term contract to convert legacy C code to C++, I did not say no. Personally I believed that it was a somewhat futile exercise since one of the main requirements was for the existing API (a functional interface written in C) to remain the same. I would have much rathered that the mandate be ab-initio, but that was not the case here. My client had a bad experience with OO, and they wanted to re-tread this path very very carefully. The...

Convert Pascal to C, C++, C# or Java
I'm currently doing a research project dealing with genetic genome matching across multiple DNA bases. I'm most familiar with Java, C, and C++. I was able to write some code to match DNA base strings against DNA base substrings across multiple genetic genomes. It works but it is very slow for large sets. As a result, to improve on the running time, I decided to research on some substring matching algorithms and I found many, but none that incorporate wildcards in C++, C, or Java. However, I was able to find a similar problem dealing with a delete that creates wildcards in a ACM progra...

Convert to C/C++?
I am wondering if someone who knows the implemention of python's time could help converting this to c/c++.... nanoseconds = int(time.time() * 1e9) # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. self.timestamp = int(nanoseconds/100) + 0x01b21dd213814000L self.clock_seq = random.randrange(1<<14L) # instead of stable storage self.time_low = self.timestamp & 0xffffffffL self.time_mid = (self.timestamp >> 32L) & 0xffffL self.time_hi_version = (self.timestamp >>...

C to C++ Syntax
Hello all, I have a question regarding syntax, coming from a C background. In C, if I had a function like this: char *ParseDelimitedString(char *String,int DelimitedNumber,char *Retval,int MaxBytes) { .... return(Retval); } This would be the way to return a string, instead of trying to return a local variable. Of course, you can malloc() within the function and return that, but I dont like having the caller know he has to free() it, but I digress.. In C++, if I had this function as a static function, in some StringUtil class: std::string &StringUtil::ParseDelimitedString(strin...

Converting C to C++
How would I go about converting this C code to C++? /* LIBRARY is an array of structures */ /* This function compares 'tcode' with */ /* existing codes in the array. */ /* It returns the index of the code in */ /* the LIBRARY structure if it is found. */ int findcode( LIBRARY *b, int n, char *tcode ) { int i; for( i = 0; i < n; i++ ) if( strcmp( b[i].code, tcode ) == 0 ) return i; return -1; } This is what I have: (I just need to know if the code exists [ie, function returns 1] in the class. Indeces are not necessary.) c...

How to convert C to C++?
I want to convert C programs to C++ programs. I found this tool http://www.scriptol.com/scripts/ctocpp.php But I'm wondering if this is the best tool to convert C programs to C+ + programs. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] Peng Yu wrote: > I want to convert C programs to C++ programs. Most C programs are also C++ programs themselves, except that some identifiers (such as 'class', 'delete') may conflict with keywords. C++ does not require its progra...

From c++ string to c
hello , i ma new in this group and writing over the fact that i have a small project at hand,i am writing a program which can permit the input of a text of arbitary lenght,and the number of double vowels must be determined. Output:frequency of each double vowel ,must be dtermined. e.g. Later ,we will see you again OUTPUT:1xee,1xou,1xai. I already wrote one but using the new library string type string,but i wish to do this for a particular purpose and hence wish to use rather the c string and functions from <string.h>, e.g strcpy,....but i am also very new in c so i have not understood...

C++ strings & C strings
i was doing exercise 4.3.1 - 4.29 of "C++ Primer 4/e" where authors, with "run-time shown", claim that C++ Library strings are faster than C-style character strings. i wrote the same programme in C & hence found that claim of the authors is *partial*. If we use C-style strings in C++ instead of Library String class, then they are slow but if write the same programme in C then C strings are "faster" than both C++ Library strings & C-style strings in C++. Below is the code of 3 programmes. i will really appreciate any comments on C++ programming, regarding ...

Web resources about - Convert string to C expression syntax - comp.lang.c.moderated

Closed-form expression - Wikipedia, the free encyclopedia
In mathematics , an expression is said to be a closed-form expression if it can be expressed analytically in terms of a finite number of certain ...

Fighting abuse to protect freedom of expression
We believe that protection from abuse and harassment is a vital part of empowering people to freely express themselves on Twitter. Today, as ...

Campus no longer safe place for freedom of expression says free speech advocate
A group representing free speech in Canada says universities are no longer safe places for free expression, instead shying away from being forums ...

Apple acquires ‘Emotient’ facial expression & emotion detection technology
The Wall Street Journal reports Apple has confirmed it has made an acquisition of artificial intelligence startup Emotient . The cloud-based ...

Turkey setting ‘poor example’ for freedom of expression: Biden
Turkey setting ‘poor example’ for freedom of expression: Biden

Facial Expressions and Tail Expressions
Submitted by: (via Daniel J Farrell ) Tagged: dogs , face , expression , tail , wag Share on Facebook

Duke Student Columnist: America’s First Amendment ‘Obsession’ Is ‘Expression Of White Supremacy’
Duke Student Columnist: America’s First Amendment ‘Obsession’ Is ‘Expression Of White Supremacy’

Leonardo DiCaprio Reacts to Lady Gaga's Golden Globes Win See His Hilarious Expression!
Leonardo DiCaprio Reacts to Lady Gaga's Golden Globes Win See His Hilarious Expression!

US: Joe Biden slams Turkey for ‘poor example’ of freedom of expression
US Vice President Joe Biden has criticised Turkey for “setting a poor example” in the region concerning freedom of expression. The damning comments ...

Apple Buys A Startup That May Help It Read Your Facial Expressions
The Emotient software could be used to make Siri more aware of the moods of her human masters. Apple wants its devices to understand the emotional ...

Resources last updated: 2/8/2016 10:06:45 PM