gcc_manual
参考
(1)-o 选项:可以指定编译后输出的可执行文件的名称。
如:helloworld.c 编译后指定输出文件名为test,使用方式如下:
gcc -o test helloworld.c
(2)-c 选项:只编译C语言代码,不进行汇编连接。
如 gcc -c helloworld.c 会产生一个叫 helloworld.o 的目标文件。
(3)-S 选项,编译并产生汇编源文件。
如 gcc -S helloworld.c 会产生一个 helloworld.s 的汇编源文件。
(4)-E 选项,只对C源文件进行预处理。
如 gcc -E helloworld.c 只对C源文件中的宏和预处理进行展开,不编译C源文件。
————————————————
g++ --->
(1)-o :可以指定输出文件名,在编译为目标代码时,这一选项不是可以忽略的。如果没有指定输出文件名,缺省文件名是a.out。
(2)-c:只编译生成目标文件,不链接。
(3)-E:只运行 C 预编译器。
(4)-S:编译并产生汇编源文件。
oneWayList.h
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef int DateType;
typedef struct SListNode
{
DateType data;
struct SListNode* next;
}SLNode;
void printSL(SLNode *head);
SLNode* createNode(DateType x);
void backPush(SLNode** head,DateType x);
void frontPush(SLNode** head,DateType x);
void backPop(SLNode** head);
void frontPop(SLNode** head);
void insertSL(SLNode** head,SLNode* pos ,DateType x);
void deleteSL(SLNode** head,SLNode* pos);
void SListDestroy(SLNode** pphead);
SLNode* SListFind(SLNode* phead,DateType x);
void SListInsertAfter(SLNode* pos, DateType x);
oneWayList.c
#include<stdio.h>
#include<stdlib.h>
#include "oneWayList.h"
SLNode* createNode(DateType x)
{
SLNode* newnode = (SLNode*)malloc(sizeof(SLNode));
if(NULL == newnode)
{
printf("malloc fail");
exit(-1);
}
newnode->data = x;
newnode->next = NULL;
return newnode;
}
void backPush(SLNode** head,DateType x)
{
assert(head);
SLNode *newnode = createNode(x);
if((*head) == NULL)
{
*head = newnode;
}
else
{
SLNode* cur = *head;
while(cur->next != NULL)
{
cur = cur->next;
}
cur->next = newnode;
}
}
void frontPush(SLNode** head,DateType x)
{
assert(head);
SLNode *newnode = createNode(x);
newnode->next = *head;
*head = newnode;
}
void printSL(SLNode *head)
{
while(head)
{
printf("%d ", head->data);
head = head->next;
}
printf("/n");
getchar();
}
void backPop(SLNode** head)
{
assert(head && *head);
SLNode *end = *head;
if(end->next == NULL)
{
free(end);
*head =NULL;
}
else
{
while(end->next->next != NULL)
{
end = end->next;
}
free(end->next);
end->next = NULL;
}
}
void frontPop(SLNode** head)
{
assert(head && *head);
SLNode* code = *head;
*head = code->next;
free(code);
code = NULL;
}
void SListDestroy(SLNode** head)
{
assert(head);
SLNode* p = *head;
SLNode* cur = *head;
while(p)
{
p=p->next;
free(cur);
cur = p;
}
*head = NULL;
}
SLNode* SListFind(SLNode* head,DateType x)
{
while(head)
{
if(head->data == x)
{
return head;
}
head = head->next;
}
return NULL;
}
void insertSL(SLNode** head,SLNode* pos ,DateType x)
{
assert(pos && *head);
SLNode *p = *head;
}
void SListInsertAfter(SLNode* pos, DateType x)
{
SLNode* newnode = createNode(x);
newnode->next = pos->next;
pos->next = newnode;
}
void deleteSL(SLNode** head,SLNode* pos)
{
assert(head);
SLNode *p = *head;
if(*head == pos)
{
frontPop(head);
}
else
{
while (p->next != pos)
{
p = p->next;
}
p->next = pos->next;
free(pos);
}
}
text.c
#include <stdio.h>
#include <stdlib.h>
#include "oneWayList.h"
void test()
{
SLNode *sl = NULL;
int i = 1;
backPush(&sl,1);
backPush(&sl,2);
backPush(&sl,3);
backPush(&sl,4);
backPush(&sl,5);
backPush(&sl,0);
printSL(sl);
SLNode *pos = SListFind(sl,0);
pos = SListFind(sl,5);
while(pos)
{
SListInsertAfter(pos,20);
pos = SListFind(pos->next,3);
}
printSL(sl);
frontPop(&sl);
frontPop(&sl);
printSL(sl);
backPop(&sl);
printSL(sl);
}
int main() {
test();
return 0;
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂
· 凌晨三点救火实录:Java内存泄漏的七个神坑,你至少踩过三个!