Question: I have this piece of code which keeps throwing a 'buffer too small' error during debug.

```
        geoGraph.size=limit;
        CString xAxis ="X axis: ",yAxis="Y axis: ";

        for (int x = 0; x < limit; x++)
        {

            xAxis.Format(_T("%s%i  "),xAxis,(x+1));
            yAxis.Format(_T("%s%s  "),yAxis,dialog_test.str[x]);

        }

        xAxis.Format(_T("%s \n%s  "),xAxis,yAxis);// <---Error thrown

        d.SetWindowTextA(xAxis);

```

I came into the conclusion that the error was due to the fact that the Cstring xAxis is too small to contain the new text, am I correct and if so, how do I remedy it?

Thanks.

Edit: I'm curios as to why this error is only shown during debugging and not when I'm running the application with 'start without debugging' (I use VS2008).

Answer: 
If your objective is to reuse the variables, you can do:

```
    geoGraph.size=limit;
    CString xAxis ="X axis: ",yAxis="Y axis: ";

    for (int x = 0; x < limit; x++)
    {

        xAxis.Format(_T("%s%i  "), CString(xAxis),(x+1));
        yAxis.Format(_T("%s%s  "), Cstring(yAxis),dialog_test.str[x]);

    }

    xAxis.Format(_T("%s \n%s  "), CString(xAxis),yAxis);

    d.SetWindowTextA(xAxis);

```

I had a similar situation and it worked, because I am now using a copy of the xAxis variable instead of it directly.
Problem solved. Used;

```
xAxis.AppendFormat(_T("\n%s  "),yAxis);

```