Question

Hi i have a problem!
i created 3 source files, and i cant find how i can add them in my program.
i dont mean the include.
i mean to give the option to the user to choose wich of the 3 files he wants to run.
Thx a lot for your time.




#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <deque>
#include <list>
#include <queue>
#include "Graph"
#include "askisi1"
#include "askisi2"


int main(){
/*here i want to call Graph*/

cout << "8elete algori8mo tou prim patiste 1 alliws algori8mo tou kruskal patiste 2";
scanf ("%d", &X);
if X=1;

/*here i want to call askisi1*/

else if X=2;
/*here i want to call askisi2*/
else
cout <<"Oi epiloges einai 1 'h 2 ";

}
return 0
}
You can't call files. you can only call functions in those files...

example:
1
2
3
4
5
6
7
//main.cpp
#include "file.h"

int main(){
    DoSomething();
    return 0;
}

1
2
3
4
5
6
7
//file.h
#ifndef FILE_H
#define FILE_H

void DoSomething();

#endif 

1
2
3
4
5
6
//file.cpp
#include "file.h"

void DoSomething(){
    //do whatever the function is supposed to do
}


And don't forget to properly link the source files.
Last edited on
thx a lot il try it :)
hmm it is not working.. sorry to bother you again i want to run
#include <stdio.h>



int X;
int main(){
printf("Give the X of the array");
scanf ("%d", &X);
int Y=X
int X,Y;
int a;
a=malloc(X*sizeof(int));
for(i=0; i<X; i++)
a[i]=malloc(Y*sizeof(int));
int Graph[X,Y];

for (int i=0; i<=X; i++){

for (int j=i; j<=Y; j++){

Printf("Give ",X,Y);
scanf("%d%d",&n,&m);
Graph[X,Y]=[n,m];
}
}

}





in this



#include <stdio.h>
#include <list>
#include <queue>
#include "Graph"


int main(){

// i want here to call the graph from the up program.. thx!





Sorry but im new to programing...
one program cannot have two int main()s
Topic archived. No new replies allowed.