Thread: Issue with strings

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    4

    Issue with strings

    Arg, ok, I'm reading in lines from a file. I'm then searching for a substring in the line I read in. If it's present, I then search for a particular character ('[') using strchr. Now, how would I go about extracting the 11 characters after the '[' into a new string? I just can't get it to work. I've tried something like this.

    char line[200];
    // stuff to get line
    char * position;
    int index;
    position = strchr(line, '[');
    index = -(line - position);
    char date[11];
    for (int i = 1; i <= 11; i++)
    strcat(date, line[index+i]);


    However, I get an error about converting char to const char*. I realize these are the parameters of strcat, but I can't think of how to do this otherwise. I can't make line a const char* because I have to keep reading into it and changing its contents.

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    Nevermind..found a solution.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "sizeof" character strings - output issue
    By bunko in forum C Programming
    Replies: 3
    Last Post: 12-03-2008, 06:10 PM
  2. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  3. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. made some progress on strings.. still one issue
    By ss3x in forum C++ Programming
    Replies: 0
    Last Post: 04-21-2002, 10:37 PM