I encountered a problem while working on a project. I know there are many simillar questions that are answered, but regarding this special one I could not find any help. I am getting the following error:
Compiling main.c
main.c:42:1: error: expected identifier or '(' before '~' token
~
^
Makefile:47: recipe for target 'obj/main.o' failed
make: *** [obj/main.o] Error 1
EDIT: I deleted the last lines of the code, but the error still occures at the line after the last '}'.
The project is about the PageRank Algorithm, using options in the console for choosing what algorithm is wished to be used. I am trying to read or use the options in the command line, but the error stops me from even looking at the semantic of my program.
/*
* main.c
*
*Programmierung 2 - Projekt 2 (PageRank)
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include "utils.h" //is existing in the Directory
int main (int argc, char *const *argv) {
//initialize the random number generator
rand_init();
printf("You gave %d command line arguments%c\n", argc-1, argc==1 ? '.' : ':');
int graph;
int i = 1;
char * h = "-h show this help. \n";
char * p = "...";
char * m = "...";
char * r = "...";
char * s = "...";
while ((graph = getopt(argc, argv, "hmprs")) != -1) {
switch (graph) {
default : printf("make -h | -m | -p | -r | -s "); break;
case 'h' : printf("%s %s %s %s %s"), h, m, p, r, s); break;
//this-like outcommended code like the one above
//and again
//and once more
//and a final one
}
printf(" - %s\n", argv[i]);
i++;
}
exit(0);
}
One more thing: I encountered a problem regarding the lengh of the case 'h' : printf(), so I outcoded the text in multiple chars. If you need more information about anything, ask me.
I got it now. My compiler (vim) added lines out of my sight. I used another editor and could delete the unnessecary code properly. Yes, was my bad all along. I am deeply sorry, it was a long day.