overwrite words in textpad

This is a discussion on overwrite words in textpad within the C++ Programming forums, part of the General Programming Boards category; hi, im having a problem overwriting a word (not appending or any other sort of thing), from a text file. ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    5

    overwrite words in textpad

    hi, im having a problem overwriting a word (not appending or any other sort of thing), from a text file. Actually, i have no idea how to do it. Im using c++. The thing is, i make the user input a string, and replace it with a word in the text file.
    I also have another problem, you see, i want to store the result of ' system("ver") ' in a string, is it possible to store system commands or not? if its not, could someone please tell me how to detect an operating system with c++.
    Thanks.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    The thing is, i make the user input a string, and replace it with a word in the text file.
    Why don't you describe in detail what you want to happen here. Maybe write down 1-5 on a piece of paper and fill in the exact steps.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    west,

    If you don't know how to do any of this, take some time to work your way through the tutorials. You'll learn about strings, user input and file I/O.

    Then, here's how I suggest you proceed:

    1- Make a string and replace one character in the string. (No user input yet).
    2- Replace a word in the string.
    3- When that works, add user-input. Get the string from the user.
    4- When your string-replacement works with user input, add the code to read the string from the file.

    system() returns an int, not a string.
    system
    int system(const char *s);
    If s is not a null pointer, the function passes the string s to be executed by a command processor, supplied by the target environment, and returns the status reported by the command processor. If s is a null pointer, the function returns nonzero only if the target environment supplies a command processor. Each implementation defines what strings its command processor accepts.
    If you're running Windows, #include <windows> and use GetVersion().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 02:22 PM
  3. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 10:01 AM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM

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