ERROR.

For this lab it just has errors if someone can figure out why it would be very helpful.

//Define Stuff
#define STARS "\t**************************************\n"
#define BOSS "\tKenneth\n"
#define PROTO "\tInternet Protocol Address Program\n"
#define EQUAL "\t=================================\n"
#define SLASH "\t//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n"
#define SLASH2 "\t\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////\n"
#define CONT "\tPress any key to continue...\n\n"
#define PERC "\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"

//Function list
void Output2 (void);
char getclass (const int IP1);
void Menu (void);
void Output3 (void);
void Output4 (void);
void Output5 (void);
void Instructions (void);

//Global Variables
int IP1[4];
int IP2[4];
int IP3[4];

char ipname1[25];
char ipname2[25];
char ipname3[25];
char IPClassA;
char IPClassB;
char IPClassC;

//Libs
#include <stdio.h>
#include <conio.h>
#include <iostream>

int main (void)
{
Menu();
return 0;
}


void output2 (void)
{
int ipcheck;
int loopredo;
loopredo = 1;



system("cls");
printf(PROTO);
printf(EQUAL);
do
{

ipcheck=0;


while (ipcheck == 0)
{
printf("Enter Ip Name:");
scanf("%s",ipname1);
printf("Input IP Address:");
scanf("%d.%d.%d.%d",&IP1[0],&IP1[1],&IP1[2],&IP1[3]);

if ((IP1[0] >=0) && (IP1[0] <=255) && (IP1[1] >=0) && (IP1[1] <=255) && (IP1[2] >=0) && (IP1[2] <=255) && (IP1[3] >=0) && (IP1[3] <=255))
{
ipcheck = 1;
}
else
{
printf("ERROR:Invalid IP");
getch();
ipcheck = 0;
}
printf("Enter Ip Name:");
scanf("%s",ipname2);
printf("Input Second IP Address:");
scanf("%d.%d.%d.%d",&IP2[0],&IP2[1],&IP2[2],&IP2[3]);

if ((IP2[0] >=0) && (IP2[0] <=255) && (IP2[1] >=0) && (IP2[1] <=255) && (IP2[2] >=0) && (IP2[2] <=255) && (IP2[3] >=0) && (IP2[3] <=255))
{
ipcheck = 1;
}
else
{
printf("ERROR:Invalid IP");
getch();
ipcheck = 0;
}
printf("Enter Ip Name:");
scanf("%s",ipname3);
printf("Input Third IP Address:");
scanf("%d.%d.%d.%d",&IP3[0],&IP3[1],&IP3[2],&IP3[3]);

if ((IP3[0] >=0) && (IP3[0] <=255) && (IP3[1] >=0) && (IP3[1] <=255) && (IP3[2] >=0) && (IP3[2] <=255) && (IP3[3] >=0) && (IP3[3] <=255))
{
ipcheck = 1;
}
else
{
printf("ERROR:Invalid IP");
getch();
ipcheck = 0;

}

}

system("cls");
printf("To Exit the loop press [Q] to re-enter the ip address's press [R]");

switch(toupper(getch()))
{
case 'Q' :
loopredo = 0;
break;

case 'R' :
loopredo = 1;
break;
default: printf("Invalid Menu Selection\n");
}

}while(loopredo == 1);



IPClassA = getclass (IP1[0]);
IPClassB = getclass (IP2[0]);
IPClassC = getclass (IP3[0]);

system("cls");
printf ("\tIP1==>> %d.%d.%d.%d \n", IP1[0],IP1[1],IP1[2],IP1[3]);
printf ("\tName ==>> %s \n",ipname1);
getch();
printf ("\tIP2==>> %d.%d.%d.%d \n", IP2[0],IP2[1],IP2[2],IP2[3]);
printf ("\tName ==>> %s \n",ipname2);
getch();
printf ("\tIP3==>> %d.%d.%d.%d \n", IP3[0],IP3[1],IP3[2],IP3[3]);
printf ("\tName ==>> %s \n",ipname3);
printf ("\t %s \n",EQUAL);
printf ("\t %s ",CONT);
getch();
}

char getclass (const int ip)
{

if (ip < 128 )
return 'A';

else if (ip < 192 )
return 'B';

else if (ip < 224 )
return 'C';

else if (ip < 240 )
return 'D';
else
return 'E';

}

void Menu (void)
{
int menuloop;
menuloop = 0;

system("cls");

do
{
system("cls");
printf (PROTO);
printf(EQUAL);

printf("\n\n\tSelect an operation to perform.\n\n");

printf("\n\n\tI=>> Show [I]nstructions\n");
printf("\tE=>> [E]nter IP Address Details\n");
printf("\tD=>> [D]isplay IP Address Details\n");
printf("\tA=>> Display [A]nalysis of IP Address Details\n");
printf("\tQ=>> Quit Program\n");

switch(toupper(getch()))
{
case 'I' :{
Instructions();
menuloop = 0;
break;
}

case 'E' :{
Output2();
menuloop = 0;
break;
}

case 'D' :{
Output3();
menuloop = 0;
break;
}

case 'A' :{
Output4();
menuloop = 0;
break;
}


case 'Q' :{
Output5();
menuloop = 1;
break;
}

default: printf("Invalid Menu Selection\n");
system("cls");
}
}while (menuloop == 0);
}
void Output3 (void)
{
system("cls");
printf ("\n\n\t %s \n\n",PROTO);
printf (SLASH);
printf ("\tThe recorded IP Addresses are -\n");
printf ("\t1. %d.%d.%d.%d\t%s\n" ,IP1[0],IP1[1],IP1[2],IP1[3],ipname1);
printf ("\t2. %d.%d.%d.%d\t%s\n" ,IP2[0],IP2[1],IP2[2],IP2[3],ipname2);
printf ("\t3. %d.%d.%d.%d\t%s\n" ,IP3[0],IP3[1],IP3[2],IP3[3],ipname3);
printf (SLASH2);
printf ("\t %s ",CONT);
getch();
}

void Output4 (void)
{
int SUMIP1;

system("cls");
printf ("\n\n\t %s \n\n",PROTO);
printf ("\t%%%%%%%%%%%%%%%%%%%% Analysis %%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
printf ("\tIP Address Name Class\n");
printf ("\t=============== =====\n");
printf ("\t1. %d.%d.%d.%d\t\t %c\n" ,IP1[0],IP1[1],IP1[2],IP1[3],IPClassA);
printf ("\t1. %d.%d.%d.%d\t\t %c\n" ,IP2[0],IP2[1],IP2[2],IP2[3],IPClassB);
printf ("\t1. %d.%d.%d.%d\t\t %c\n" ,IP3[0],IP3[1],IP3[2],IP3[3],IPClassC);
printf ("\t %s \n",PERC);

SUMIP1 = IP1[0] + IP1[1] + IP1[2] + IP1[3]+ IP2[0] + IP2[1] + IP2[2] + IP2[3] + IP3[0] + IP3[1] + IP3[2] + IP3[3];
printf ("\tThe sum of all IP address is: %d", SUMIP1);
printf ("\n\t %s \n",CONT);
getch();

}
void Output5 (void)
{
system("cls");
printf ("\n\n\n\t %s \n\n",PROTO);
printf ("\tThis program has finished.\n");
printf ("\t\tKenneth Lee\n");
getch();
}




void Instructions (void)
{
system("cls");
printf ("\t These are the instructions");

getch();
}
What is the error?
Post your compiler output and put your code into code tags . Use the <> button on the right under format.
Compiling...
lab 5.cpp
h:\progc\lab 5.cpp(247) : warning C4129: '/' : unrecognized character escape sequence
Linking...
lab 5.obj : error LNK2001: unresolved external symbol "void __cdecl Output2(void)" (?Output2@@YAXXZ)
Debug/lab 5.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

lab 5.exe - 2 error(s), 1 warning(s)
1
2
3
4
5
6
7
8
9
10
//Define Stuff
#define STARS "\t**************************************\n"
#define BOSS "\tKenneth\n"
#define PROTO "\tInternet Protocol Address Program\n"
#define EQUAL "\t=================================\n"
#define SLASH "\t//////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n"
#define SLASH2 "\t\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////\n"  
#define CONT "\tPress any key to continue...\n\n"
#define PERC "\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"


it is hard to tell but i think you have an odd number of '\' in the #define SLASH2, try adding or deleting one and see if that gets rid of this error:

h:\progc\lab 5.cpp(247) : warning C4129: '/' : unrecognized character escape sequence

EDIT: The error basically states that you have an escape '\' followed by an '/' which is not recognized as a vaild escape sequence i believe.

Last edited on
Topic archived. No new replies allowed.