标题基本上都说明了。
我需要从char数组中删除中间元素。
然后我需要在仅使用指针的情况下调整它的大小。
我不能在创建静态数组和动态新数组declerations之外使用任何数组或[]括号,例如int *temp = new int[6];
这是我目前的代码
#include <iostream>
#include <cstdlib>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
// Static Arrays
char myChar[14] = {'H', 'e', 'l', 'l', 'o', ' ', 'F', 'r', 'i', 'e', 'n', 'd', '!', '\0'};
// Pointers
char *temp3 = myChar;
char *temp4 = newChar;
cout<<"\n\nThis is the original element for the char array.\n\n";
cout<<"\t";
for(int i = 0; i < 13; i++)
{
cout<<"["<<*temp3<<"] ";
temp3++;
}
temp3 = myChar;
cout<<"\n\nThis prints out every other character in the char array.\n\n";
cout<<"\t";
for(int i = 0; i < 13/2; i++)
{
temp3++;
cout<<"["<<*temp3<<"] ";
temp3++;
}
// Attempt at splitting it by the first six digits
temp3 = myChar;
cout<<"\n\nThis prints out every other character in the char array.\n\n";
cout<<"\t";
for(int i = 0; i < 6; i++)
{
}
return 0;}