CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    2

    String File names

    So I have a stack of pictures that I need to read and I've named them target0, target1, target2, etc. but to type each of those into a string like:

    textureFilename[0] = "target1.png";


    is inconvenient. Is there a way I can make the number in the string an integer value, similar to a printf, so that I can just put this in a loop?

    What I mean by a printf is:

    printf("target%d.png", i);

    is there something I can do like this for entering a string name in?

    Thanks!

  2. #2
    Join Date
    Jul 2006
    Posts
    297

    Re: String File names

    I think this is what you're looking for.

    Code:
    String.Format("target{0}d.png", i);

  3. #3
    Join Date
    Aug 2009
    Posts
    2

    Re: String File names

    that worked awesome thanks for the help

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: String File names

    monalin's suggestion is the way to go, but you could have always just concatenated the string or used a StringBuilder inside of the loop.
    Last edited by BigEd781; August 13th, 2009 at 07:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured