simple c question 
Author Message
 simple c question

I am looking for a command which will give the length of a string which includes the spaces and invisible chars.

TIA



Fri, 25 Aug 2000 03:00:00 GMT  
 simple c question

With the exception of the value '\0' [NUL] the strlen() function will do what
you want.  There are no commands in C, but it is clear what  you mean.

--
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ ftp: ftp://rtfm.mit.edu, C-FAQ Book: ISBN 0-201-84519-9
Try "C Programming: A Modern Approach" ISBN 0-393-96945-2
Want Software?  Algorithms?  Pubs? http://www.infoseek.com

I am looking for a command which will give the length of a string which
includes the spaces and invisible chars.

TIA



Fri, 25 Aug 2000 03:00:00 GMT  
 simple c question

Quote:

> I am looking for a command which will give the length of a string which includes the spaces and invisible chars.

> TIA

try strlen()


Sat, 26 Aug 2000 03:00:00 GMT  
 simple c question

Quote:

> I am looking for a command which will give the length of a string which
> includes the spaces and invisible chars.

        You want the strlen() function.  Observe the following example (be sure
to include the string.h header in your source file),

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

        int main( void);

        int main( void) {
                char someText[32];
                int  lenText;

                strcpy( someText, "Here is a String.\001");
                printf( "%s\n", someText);
                lenText = strlen( someText);
                printf( "length = %d\n", lenText);

                return 0;
        }

        The \001 is one of those usually invisible characters you mentioned,
a control code, that is sometimes represented by an ASCII happy face. strlen()
will count all characters except nul (ASCII 0) which is conventionally used as
a terminator.  If counting the nul is important to you, you can add 1 to the
result of strlen().
                                                        -- Stone



Sat, 26 Aug 2000 03:00:00 GMT  
 simple c question


Quote:

>SSBhbSBsb29raW5nIGZvciBhIGNvbW1hbmQgd2hpY2ggd2lsbCBnaXZlIHRoZSBsZW5ndGggb2Yg
>YSBzdHJpbmcgd2hpY2ggaW5jbHVkZXMgdGhlIHNwYWNlcyBhbmQgaW52aXNpYmxlIGNoYXJzLg0K
>DQpUSUENCg==

This is what your post looks like to the significant proportion of
newsreaders which do not decode Base 64.  Please configure your posting
software to post in "text/plain", or switch to an alternate reader.

Cheers,
Richard
--
Richard Stamp
Churchill College, Cambridge



Sat, 26 Aug 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. a simple simple question...

2. simple simple print question

3. Simple ListBox question

4. Simple Mutex question

5. Simple casting question

6. Simple String Question

7. a very simple malloc question

8. simple syntax question

9. Simple Beginner Question

10. Simple (stupid) question: why does sqrt work?

11. A simple C question

12. Simple C Question

 

 
Powered by phpBB® Forum Software