缩小缓冲区时重新分配会失败吗?

时间:2019-05-17 18:08:39

标签: c realloc

当新大小小于缓冲区的旧大小时, string alt; bool firstRun = true; do { if (firstRun) { firstRun = false; GameLogic(); } Console.WriteLine("Play again?"); Console.WriteLine("[Y]es | [N]o"); alt = Console.ReadLine(); alt.ToLower(); if (alt == "Y" || alt == "y") { Console.Clear(); GameLogic(); } else if (alt == "N" || alt == "n") { break; } else { Console.WriteLine("Invalid input!"); } } while (alt != "N" || alt != "n"); Console.WriteLine("\nPress any key to quit..."); Console.ReadKey(); 是否有可能失败?在此示例中,缓冲区的大小从100字节调整为50字节。

realloc

0 个答案:

没有答案