I want to loop my program to create a folder in Dropbox. Once it successed, to get out of loop. For example, if "fld0", "fld1", "fld2" exist, make fld3 and get out of loop. But the problem is that my program thinks that it created a folder "fld0" successfully, even if "fld0" was created before. In my code I can actually change
HTML Code:
json.UpdateBool("autorename", false);
to true. But I want to have a variable equal to "fld%d" of successfully created the new folder (if "fld0", "fld1", "fld2" exist, get equality of "fld3"). How it can be done?

HTML Code:
#include "pch.h"
#include <iostream>
#include <fstream>
#include<istream>
#include<string>
#include <Windows.h>
#include <tchar.h>
#include <CkRest.h>
#include <CkJsonObject.h>
#include <CkStream.h>
#include <CkDateTime.h>
#include <CkDtObj.h>
#include <CkGlobal.h>
#include <CkRest.h>
#include <CkJsonObject.h>
#include <CkStringBuilder.h>
#include <CkCrypt2.h>

using namespace std;



void ChilkatSample(void)
{
    // The Chilkat API can be unlocked for a fully-functional 30-day trial by passing any
    // string to the UnlockBundle method.  A program can unlock once at the start. Once unlocked,
    // all subsequently instantiated objects are created in the unlocked state. 
    // 
    // After licensing Chilkat, replace the "Anything for 30-day trial" with the purchased unlock code.
    // To verify the purchased unlock code was recognized, examine the contents of the LastErrorText
    // property after unlocking.  For example:
    CkGlobal glob;
    bool success = glob.UnlockBundle("");
    if (success != true) {
        std::cout << glob.lastErrorText() << "\r\n";
        return;
    }

    int status = glob.get_UnlockStatus();
    if (status == 2) {
        std::cout << "Unlocked using purchased unlock code." << "\r\n";
    }
    else {
        std::cout << "Unlocked in trial mode." << "\r\n";
    }

    // The LastErrorText can be examined in the success case to see if it was unlocked in
    // trial more, or with a purchased unlock code.
    std::cout << glob.lastErrorText() << "\r\n";
}

void ChilkatSample0(void)
{

    CkRest rest;
    bool success;

    //  URL: https://api.dropboxapi.com/2/files/create_folder_v2
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect("api.dropboxapi.com", port, bTls, bAutoReconnect);
    if (success != true) {
        std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
        std::cout << rest.lastErrorText() << "\r\n";
        //return;
    }

    //  See the Online Tool for Generating JSON Creation Code
    CkJsonObject json;

    int i = 0;
    char folder[100];
    for (;;)
    {
        sprintf(folder, "/fld%d", i++);

        json.UpdateString("path", folder);
        json.UpdateBool("autorename", false);

        rest.AddHeader("Authorization", "Bearer access_token");
        rest.AddHeader("Content-Type", "application/json");

        CkStringBuilder sbRequestBody;
        json.EmitSb(sbRequestBody);
        CkStringBuilder sbResponseBody;
        success = rest.FullRequestSb("POST", "/2/files/create_folder_v2", sbRequestBody, sbResponseBody);

        if (success == true) {
            std::cout << rest.lastErrorText() << "\r\n";
            return;
    }
    }


int main()
{
    ChilkatSample();
    ChilkatSample0();
}