Я сделал программу, которая все еще находится в разработке.Я не объявлял main в своей программе преднамеренно. Поскольку я разрабатываю библиотеку для создания графиков и другой алгоритм, который я буду использовать в своих программах. Цель разработки такой библиотеки на C - это работать над проблемами, изложенными в книге ВведениеАлгоритмы Томас Х Coreman Вот код, если кто-то хочет увидеть.
#include<stdio.h>
#include<stdlib.h>
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node *graph;
graph cnode(int data); //cnode is to create a node for graph
void cgraph(void);
struct node {
int data, color;
struct node *LEFT, *RIGHT, *TOP, *DOWN;
};
graph root = NULL;
void cgraph(void)
{
int n, choice, dir, count;
choice = 1;
count = 1;
graph priv, temp;
printf("Printf we are making a graph the first is root node\n");
while (choice == 1) {
count++;
if (count == 1) {
printf("This is going to be root node \n");
scanf("%d", &n);
root = cnode(n);
count--;
priv = root;
} //ending if
else {
printf
("Enter direction you want to go LEFT 1 RIGHT 2 TOP 3 DOWN 4\n");
scanf("%d", &dir);
printf("Enter the data for graph node\n");
scanf("%d", &n);
temp = cnode(n);
if (dir == 1) {
priv->LEFT = temp;
}
if (dir == 2) {
priv->RIGHT = temp;
}
if (dir == 3) {
priv->TOP = temp;
}
if (dir == 4) {
priv->DOWN = temp;
}
priv = temp;
} //ending else
printf
("Enter 1 to continue adding nodes to graph any thing else would take you out\n");
scanf("%d", &choice);
} //ending while
} //ending main
graph cnode(int data)
{
graph temp = (graph) malloc(sizeof(graph));
temp->data = data;
temp->LEFT = NULL;
temp->RIGHT = NULL;
temp->TOP = NULL;
temp->DOWN = NULL;
temp->color = -1;
return temp;
}
Когда я скомпилировал вышеупомянутую программу, я получил следующую ошибку.почему я должен объявить main в моей программе?