Hey, i'm new here and hoping to get a few noobish questions answered

This is a discussion on Hey, i'm new here and hoping to get a few noobish questions answered within the C Programming forums, part of the General Programming Boards category; A buffer is stored in memory somewhere. Ptr is a pointer to an address that specifies a region within that ...

  1. #31
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    A buffer is stored in memory somewhere.
    Ptr is a pointer to an address that specifies a region within that buffer to copy.
    And the word is a pointer to a buffer that malloc created for you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #32
    Registered User
    Join Date
    Jan 2008
    Posts
    79
    ok! phewwwww. well ive taken most of that in. Must seem simple to you. But im finding it hard to work it out to be honest. Thanks for all your help

  3. #33
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Sure, when you've programmed several years, it seems a piece of cake to you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #34
    Registered User
    Join Date
    Jan 2008
    Posts
    79
    lol i just realised. that i could just print out the words with a simple printf("%s\n",ptr); didnt even realise i could do it that simple. lol i'll know for next time. Well bed time here in ireland night night.

  5. #35
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Yes, night.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #36
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,699
    FWIW, a strtok version:
    Code:
    char ** tokenize ( const char * split_it, const char * delim, 
                       char ** string_ar, const unsigned long AR_LENGTH )
    {
        /**shouldn't assume that no one will want 'split_it' as-is later, so 
         **create a copy in memory:**/
        char * split_me = duplicate( split_it );
        char * found = NULL;
    
        if( split_me != NULL ) {
            unsigned long wordcount = 0;
    
            for( found = strtok( split_me, delim );
                 found != NULL && wordcount < AR_LENGTH;
                 found = strtok( NULL /**more matches?**/, delim ) ) 
            {   
                string_ar[wordcount] = duplicate( found );
    
                if( string_ar[wordcount] == NULL )
                    return NULL; /**failure return**/
    
                ++wordcount;
            }
            string_ar[wordcount] = NULL;  /**like argv**/
            free( split_me );
            /**free( found ); is not nexessary because it simply points
             **to a part of the recent 'split_me', and since we copied the
             **words to 'string_ar' we can safely free 'split_me'**/
        }
        return string_ar;
    }

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21