Thread: Another question....

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001

    Thumbs up Another question....

    I would like to know if there was any way that I could extend the limits of a char array (or whatever it is called) beyond 256 (or whatever the limit is) so I would be able to make some sort of cheap version of a word processor and save it to a file. And also, how would I be able to enable the user to create their own title. Here is my code to help you...

    #include <iostream>
    #include <fstream>

    using namespace std;

    ofstream output;"file.txt");

    char text[256];

    output << text;

    int var1, var2, var3, var4;


    As you can see, the file name is automaticly specified as "file.txt". And "text" is set to a limit of 255 characters. Some guy on this board wrote code similar to this and he included the line :
    "int var1, var2, var3, var4;" in it. Is this really necessary for the program to work?

    I know it's alot of questions, but I am only 13 (14 in two weeks from tommorrow) and I am still learning.


  2. #2
    Join Date
    Aug 2001
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    The input buffer will only allow the user to enter 255 characters at a time but this only applies to console applications. In order to overcome this you would have to use a Windows application.

    In 'C', you can ask for user input and open a file like this:

    char sFilename[30];
    printf("Enter the file name: ");
    FILE *fptr = fopen(sFilename,"r"); if(fptr == NULL) exit(1);
    In C++ you would do something similar with cout and cin. Once you have the user input stored in a string you can apply the array it in the function rather than using hard code such as 'file.txt'.
    Last edited by Witch_King; 08-26-2001 at 11:11 PM.
    I compile code with:
    Visual Studio.NET beta2

  3. #3
    That is not the way to do a text editor...
    You actually need to be a bit more cunning than that...
    My advice is to store each line as a node in a linked list, that way you can render the page easily and it is easy to save it, just traverse the list and save the nodes...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM