Solved

using a long to determine a string for use as a filename

Posted on 2004-10-31
228 Views
Last Modified: 2010-04-15
OK heres what im tryin to do.

Filenames are in the format XXXX.cct and XXXX is deterined by a long. So if long i = 1234, then filename would be 1234.cct. If it was 1 then filename would be 0001.cct

What is the easiest way of going about this?

Should I convert the long to a string then append the .cct?
0
Question by:kenbond
    1 Comment
     
    LVL 5

    Accepted Solution

    by:
    you can use sprintf to create the filename.
    with sprintf you can specify the format in which you will
    write in the string.

    long i = (some val);
    char name[100];
    sprintf(name, "%04d.cct", i);
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    Dll Dynamic way c/c++ 9 119
    Estimate porting issues. 9 108
    Problem in finding output of a program 11 82
    List out all word 7 159
    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now