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...
#define BUFFER_LEN 256
//declare and initialise variables
char Buffer[BUFFER_LEN];//stores input
char str; //char string
//declare function getString
void getString(char *);
//declare function dumpString
void dumpString(char *);
printf("Input a string please!!");
//read user input
getString(str); //read input