how do we build our own string functions from
scratch and not use the built in functions from the String class and
a function to open and close a file given its name. then, check whether
or not the file exists. It should read an opened file into an array of characters. assume the array is large enough to hold an entire file (e.g. 100,000 characters) then
add a function for saving the text stored in an array to a file and check
whether or not the output file already exists, and if it does, ask the
user whether he/she wishes to overwrite the file.
also how do we count the number of words and characters in the text file and add
a function for inserting a string into the array, a function for deleting strings from the array, a function that searches the text for a pattern. Show all occurrences of a string, and a function to replace all occurrences of a string with a new string. Note that this
operation is a combination of search, delete, and insert operations.

I'm new to c++ and i want to learn how to actually code the above.

If you are totally new to C++, then try some easy codes first which involves very simple file handling. Click Here
then try something with string header , then try to make programs which involves both, then try this code. After this step-by-step procedure , this code will be very easy for you. hope it helps! thanks.

nitin1 makes some good suggestions. I'd only add that we don't do your homework for you! First, try to solve the problem, and then show us your code. We will happily point out your errors, if we can...

There are at least 2 ways I can think of to write your own string function:

  1. Use a linked list of char arrays for storing the read-in-lines from the file. In a loop read a line, allocate new memory for a new node of the linked list, add the line to the node, then finally add the node to the linked list.

  2. Store all the lines of the file into the same character array -- dynamically expand the character array when each new line is read from the input file. That way you don't have to guess about how big the character array has to be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.