- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我遇到了一些问题。每次尝试编译我的程序时,我都会收到“collect2: error: ld returned 1 exit status”。我在谷歌上搜索了这个,查看了示例,发现它通常发生在头文件未正确使用时;但是,我没有在我的代码中使用头文件,所以我不确定为什么要这样做。我认为这对其他遇到此错误但不明白原因的人会有所帮助。我确实知道我的代码中有很多错误,但我正在努力找到可以编译它并解决所有问题的地方。非常感谢!!
#include <stdio.h>
#include <stdlib.h>
struct node_t {
double x;
struct node_t *next;
};
struct node_t *create_node(double n);
void print_node (struct node_t * node );
void print_list (struct node_t * head );
struct node_t * insert_head (struct node_t *head , struct node_t * node );
struct node_t * insert_tail (struct node_t *head , struct node_t * node );
struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos );
int count_nodes (struct node_t * head );
struct node_t * delete_node (struct node_t *head , double n);
void delete_list (struct node_t * head );
int main (void)
{
double n;
int pos;
/** Asks the user what they would like to do. */
printf("Please select an option: ");
printf("1. Enter a number ");
printf("2. Delete a number ");
printf("3. Print all numbers ");
printf("4. Tell how many items in the list ");
printf("5. End program ");
printf("Please enter your choice (1, 2, 3, 4, 5): ");
while ((tmp = getchar()) != '\n')
in = tmp; /** Tells the compiler to use the number that the use put in. */
switch (in){
case '1': {/** If the user chooses Enter a Number, go through this process. */
printf("1. Enter item at head of list ");
printf("2. Enter item in middle of list ");
printf("3. Enter item at tail of list ");
printf("Please enter your choice (1,2,3): ");
while ((tmp = getchar()) != '\n')
in = tmp;
switch (in) {
case '1':{
printf("Enter the number to be entered at head: ");
fgets(s, 1024, stdin);
struct node_t * create_node (double n);
struct node_t *insert_head(struct node_t *head, struct node_t *node);
break;
}
case '2':{
printf("Enter the number to be entered in middle: ");
fgets(s, 1024, stdin);
struct node_t * create_node (double n);
struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos);
break;
}
case '3':{
printf("Enter the number to be entered at tail: ");
fgets(s, 1024, stdin);
struct node_t * create_node (double n);
struct node_t *insert_tail(struct node_t *tail, struct node_t *node);
break;
}
break;
}
}
case '2':{/** If the user selected Delete a Number, go through this process. */
printf("Enter the node that needs to be deleted: ");
fgets(s, 1024, stdin);
struct node_t * delete_node (struct node_t *head , double n);
break;
}
case '3':{/** If the user selected Print All Numbers, go through this process. */
//void print_list (struct node_t *head)
break;
}
case '4':{ /** If the user selected Tell How Many Items in the List, go through this process. */
int count_nodes (struct node_t * head );
break;
}
case '5':{ /** If the user selected End Program, go through this process. */
return 1;
break;
}
}
return 0;
}
/** Creates a new node
* @param double n, a number n
* @return pointer
*/
struct node_t * create_node (double n)
{
struct node_t *p = malloc (size of (struct node_t))
p -> x = n;
p -> next = NULL; /*initializes pointer to null*/
return p;
}
/** Prints the nodes
* @param struct node_t *node
*/
//void print_node (struct node_t *node )
//{
// prints out the node and the address of the node
// print(*node, &node)
//}
/** Prints list
* @param struct node_t *head
*/
//void print_list (struct node_t *head)
//{
// print contents of list. both the doubles and the address.
// while (pointer is pointing to something, keep going through the list. )
// print(nodes in list, address of nodes )
//}
/** Inserts a node at the head
* @param struct node_t *head, the structure where head is.
* @param struct node_t *node, the structure where node is.
* @return head.
*/
struct node_t *insert_head(struct node_t *head, struct node_t *node)
{
node-> next = head;
head = node;
return head;
}
/** Inserts a node at the tail.
* @param struct node_t *tail, the structure where tail is.
* @param struct node_t *node, the structure where node is.
* @return head.
*/
struct node_t *insert_tail(struct node_t *tail, struct node_t *node)
{
struct node_t *p = head;
if (head == NULL)
head = node;
return head;
while (p->next ! = NULL)
p = p-> next;
p-> next = node;
return head;
}
/** Inserts a node at the middle.
* @param struct node_t *head, the structure where head is.
* @param struct node_t *node, the structure where node is.
* @param int pos, the position of the current node.
* @return head.
*/
struct node_t * insert_middle (struct node_t *head , struct node_t *node , int pos);
{
int pos = 1;
struct node_t *p = head;
*head = pos, pos = 1;
if (pos > SIZE )
p-> next = node;
else if (pos < 1)
printf("Error\n");
return head;
}
/** Counts the number of nodes
* @param struct node_t *head, the structure where head is.
* @return count.
*/
int count_nodes (struct node_t * head );
{
struct node_t *p = head;
while(p->next ! = NULL)
return count;
if (head == NULL)
count = 0;
return count;
}
/** Deletes nodes
* @param struct node_t *head, the structure where head is.
* @param double n, a number n.
* @return head.
*/
struct node_t * delete_node (struct node_t *head , double n);
{
if (node == head)
free head;
p->next = head; //head now points to the pointer that was next after the node that was deleted
else if (node == middle)
free node;
p = p->next //pointer before node that was deleted now points to node that was after deleted node
else if (node == tail)
free p = p->next = node; //free the last node that holds data. The node before it now points to NULL
p->next = NULL;
else printf("Error\n")
return head;
}
/** Deletes list
* @param struct node_t *head, the structure where head is.
* @return head.
*/
void delete_list (struct node_t * head );
{
while((p->next ! = NULL)
free head; //This will lose all memory after head.
head == NULL;
if (head == NULL)
return 0;
return 0;
}
最佳答案
那是链接器失败的时候。
您的文件顶部的前向声明签名可能与下面的实现不匹配。链接器找不到其中一个函数。
关于c - 我一直收到 collect2 : error: ld returned 1 exit status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19848533/
我对文档有点困惑。请纠正我。 git 状态- 显示当前本地工作目录状态 git status -u- 显示未跟踪的文件(也是本地的) git 状态 -uno- 不显示未跟踪的文件(也是本地的)?? 后
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有以下 JavaScript 代码: alert(data.status); data 是一个 JSON 对象,其字段之一是 status ( bool 字段)。 当JSON.stringify(d
我在验证表单时遇到此错误,如何解决它。 代码: app.post('/',[ check('username','Error occured in Username').trim().isEmai
我正在开发一个使用 fork() exec() wait() 的 C 程序。第一个进程有以下代码: int main(int argc, const char * argv[]) { // inser
我想在 git status 上运行 linter,但是似乎没有 pre-status 和 post-status Hook 。 如何给 git 添加一个钩子(Hook)? fine docs对此事保
我需要获取所有 current_user.friends 状态,然后按 created_at 对它们进行排序。 class User a.created_at } end current_user.
我在 Eloquent 中使用 orWhere 时遇到问题。 我有一个团队,这个团队有一些资料。我想获取状态 = 1 或状态 = 2 的所有配置文件。但我无法让它工作。 我的代码是这样的: $prof
http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT 根据这
我们在 IIS 6.0 上托管 WCF 服务的服务器之一上观察到以下行为: IIS 日志显示所用时间的值较高 (> 100000) HTTP 状态码是 200 sc-win32-status 代码显示
在 Dynamics CRM 中,潜在客户实体同时具有状态和状态原因。使用 API 我可以获得所有状态原因。我被绊倒的地方是当我的用户选择状态原因时我想倒退并找出哪个状态与所选状态原因相关联。 以下是
我很好奇返回响应和仅创建响应的区别。 我见过大量使用 return res.status(xxx).json(x) 的代码示例和res.status(xxx).json(x) . 谁能详细解释一下两者
文档并没有真正说明 status 是什么。 status 到底是什么? http://man7.org/linux/man-pages/man2/exit_group.2.html 最佳答案 来自ex
An earlier question导致了一些关于如何检查 Git 存储库是否包含脏索引或未跟踪文件的想法。我从那次讨论中采纳的答案如下: #!/bin/sh exit $(git status -
ECSHOP出现 XMlHttpRequest status:[500] Unknow status 这个错误 把/admin/templates/top.htm 这个文件中{insert_scr
我有以下代码用于通过 Twitter4J 获取推文: List statuses; Paging paging = new Paging(1, LIMIT); statuses = twitter.g
非常不言自明。我正在制作一个脚本并且遇到了被使用和解析的情况,但它们的输出似乎总是完全相同。 最佳答案 git status --branch --porcelain "显示分支的状态(ahead,
我有一张表,上面有如下记录 表A subid clickid status datetime 1 123 low 2018-07-24 20:20:44 2 123
如果确实缺少资源,我的 API 将返回以下内容 { "code": 404, "message": "HTTP 404 Not Found" } 当我使用代码 Response.sta
我是一名优秀的程序员,十分优秀!