Thread: I need help with implementing strings???

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    19

    I need help with implementing strings???

    Hi? I was wandering if any one knows anything about implementing and using strings..
    Basically i have a basic understanding of C programming and would like someone to start the problem for me...

    Basically i have to implement a function called getString() which extracts a string from standard input; stores it in an array; and returns a pointer to its starting character.

    Each call to getString() locates the next string in input and stores it after any previously stored strings.

    In storage each string is terminatted by the ASCII null character; the delimmiting quotes are omitted.

    some extra notes:

    Storage overflow must be prevented; ie if the next string to be deposited in the array would exceed its bound then extra memory must be allocated.

    The same string must not be stored more than once, ie, if a string is encountered twice, then getString() is to return a pointer to where it was stored on first encounter.

    Then i have to implement a function called dumpString(), ie, each call to dumpString() returns a pointer to the next string in storage (starting with the first); returning a NULL pointer at the end of the list.

    Also "a quote character \"inside\" a string must be escaped with the backslash character, as is the backslash character itself."

    If anyone can help me with this problem that would be great, otherwise give me some links that i could refer to for this sought of problem..


    i have started something, but not sure if is correct...

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #define BUFFER_LEN 256

    void main()
    {
    //declare and initialise variables
    char Buffer[BUFFER_LEN];//stores input
    char str[40]; //char string

    //declare function getString
    void getString(char *);

    //declare function dumpString
    void dumpString(char *);

    printf("Input a string please!!");
    fgets(str);
    //read user input
    getString(str); //read input
    Last edited by atif; 04-05-2002 at 04:03 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:34 AM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM