[futurebasic] Re: [FB] Rosetta update and request

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2002 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 8 Sep 2002 21:49:49 -0400
Defining the C function:

>strcopy()

tedd wrote:

>DIM str$
>str$ = "Hello"
>
>is the same as:
>
>char str[20];
>strcpy(str,"Hello");
>
>>strchar()
>
>I'm not sure what strchar() is.
>
>There is a "strrchr()"  [ i.e., char *strrchr(const char *str, int
>ch) ] which returns a pointer to the last occurrence of the low order
>byte of ch in the string pointed to by str. But, I don't see that to
>be a popular function.

Thanks for the help, tedd. Here is the snippet I'm trying to translate:

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
char line[256], lastcanon[256], lastword[256], *word;
   strcpy(lastcanon, "*Undefined*");
   for (;;) {
     if (gets(line) == NULL) break;
     if ((word = strchr(line, '=')) == NULL) break;
     *word++ = '\0';
     if (strcmp(line, lastcanon) == 0) {
       printf("%s = %s\n", lastword, word);
     }
     strcpy(lastcanon, line);
     strcpy(lastword, word);
   }
   return(0);
}

String handling is a breeze in FB^3 compared with C!

Ken