信息实际上并未存储在节点阵列中
Information not actually being stored inside array of nodes
node* nodeArray[1000];
for (int j = 0; j < 1000; j++){
nodeArray[j] = new node;
}
int nodeCounter = 0;
string temporary = "";
string cont; //file content
int i = 0;
while (getline(fileObject, cont)){
for (int k = 0; k < cont.length(); k++)
cont[k] = tolower(cont[k]);
while (i < cont.length()){
这是问题出现的地方。cout行告诉我,我的逻辑很好,因为它应该在我的linkedlists数组中插入节点。但这实际上并不是将它们添加到linkedlist的数组中。
//cout << "nodeArray [" << nodeCounter << "] : " << temporary << "n";
insert(nodeArray[nodeCounter], temporary);
temporary = "";
i++;
}
i = 0;
nodeCounter++;
}
这是我的插入功能,可能会弄乱程序
void insertion(node* tail, string info){
node* temp = new node;
temp->data = info;
temp->previous = tail;
temp->next = NULL;
tail = temp;
}
您是按值而不是参考传递指针,因此传递变量指向的地址没有更改。
更改 void insertion(node* tail, string info){
进入 void insertion(node*& tail, string info){
。
相关文章:
- 反向给定链表中的K节点
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- OpenMP阵列性能较差
- Boost Graph Library,修复节点大小
- C++A*算法并不总是在路径中具有目标节点
- 如何将三维尺寸不固定的三维阵列展平为一维阵列
- 如何找到2个单链表的公共节点
- 当我的阵列太大时出现分段错误
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 为什么我的删除节点函数实际上没有删除节点?
- 我们可以删除链表中静态内存中的节点吗
- 如何在pugixml中获取节点的内部XML
- 位阵列上的快速AND运算
- 为什么我们要为avl树实现返回一个指向节点的指针,而不是void函数
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 阵列必须使用大括号封闭的初始器进行初始化
- 信息实际上并未存储在节点阵列中
- 如何在C 中实现多维阵列的多个节点
- 将阵列转换为节点
- 创建节点阵列