I supposed to make in memory linked list. I thought I did it perfectly. My teacher is kind of the teacher that won't teach you but let you figure it out.. I couldn't figure it out!!! I supposed to make one like this but to manipulated the list. I am losing here...

/*------------------------------------------------------------------
* Assignment 7: FIRST LINKED LIST ASSIGNMENT.
*Worth: 50 points
*Made by: Samuel Georgeo (max11)
create
an in-memory SERIALLY linked-list database program which
displays a menu screen.
-------------------------------------------------------------------*/

#include <stdio.h>
#include <iostream>
#include "/var2/local/include/getch.h"
using namespace std ;
/*-----------------------------------------------------
* MAIN PROGRAM STARTS HERE
-----------------------------------------------------*/
int main(int argc, char *argv[1])
{
        char  b ;
        while(1)
        {
                putchar('\n') ;
                puts("\t\te) Enter a new agent");
                puts("\t\tl) List agents in file");
                puts("\t\tn) Next Struct in List");
                puts("\t\tp) Prev Struct in List");
                puts("\t\tq) Quit program");
                
	if (phere)  // avoid segfault for nonexistant record
                phere->print_rec() ;

                putchar('\n') ;
                b = getch();
                switch(b)
                {
                        case 'e':
                  if(!p){
		p = new prs;
		if (!p) exit (-1)
		p > next = p > prev = p;
		edit_rec (p);
                  }else{
	          phere = p > prev;
		pnew = new prs;
		if(!pnew) exit (-1)
		p > prev =pnew;
		pnew> next = p;
		phere > next
                  break;
  
                         case 'l':
                                puts("you typed l") ;
                                break;
                        case 'n':
                                phere= phere->getNext() ;
                                break;
                        case 'p':
                                phere= phere->getFrom();
                                break;
                        case 'q':
                                puts("you typed q") ;
                                return 0 ;
                                break;
                };  // switch case b
        };     deletelist ( head );

}       // main

The errors I got was this....

error C2143: syntax error : missing ';' before '%'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
fatal error C1004: unexpected end-of-file found

what is "/var2/local/include/getch.h" ?

where is phere declared ?

what is "/var2/local/include/getch.h" ?

where is phere declared ?

How can I delared it? :-/

How can I delared it?

#include "getch.h"

assuming this is your struct

struct myStruct{
       //details
}

typedef myStruct phere;

Because you havent formatted your code very well, you missed out a curly bracket during your switch statement. I have formatted and made the following corrections for you:

/*------------------------------------------------------------------
* Assignment 7: FIRST LINKED LIST ASSIGNMENT.
*Worth: 50 points
*Made by: Samuel Georgeo (max11)
create
an in-memory SERIALLY linked-list database program which
displays a menu screen.
-------------------------------------------------------------------*/

#include <stdio.h>
#include <iostream>
#include "/var2/local/include/getch.h"
using namespace std ;
/*-----------------------------------------------------
* MAIN PROGRAM STARTS HERE
-----------------------------------------------------*/
int main(int argc, char *argv[1])
{
	char  b;
	while(1)
	{
		putchar('\n') ;
		puts("\t\te) Enter a new agent");
		puts("\t\tl) List agents in file");
		puts("\t\tn) Next Struct in List");
		puts("\t\tp) Prev Struct in List");
		puts("\t\tq) Quit program");

		if (phere)  // avoid segfault for nonexistant record
		phere->print_rec() ;

		putchar('\n') ;
		b = getch();
		switch(b)
		{
			case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p > next = p > prev = p;
					edit_rec (p);
				} else {
					phere = p > prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p > prev = pnew;
					pnew > next = p;
					phere > next
				} // You missed this out..
				break;

			case 'l':
				puts("you typed l") ;
				break;
			case 'n':
				phere= phere->getNext() ;
				break;
			case 'p':
				phere= phere->getFrom();
				break;
			case 'q':
				puts("you typed q") ;
				return 0 ;
				break;
		};  // switch case b
	};
	deletelist (head);
}// main

Is this a C program or C++ ? You included c++ iostream but ignored it and used C printf().

Some more corrections in red ...

/*------------------------------------------------------------------
* Assignment 7: FIRST LINKED LIST ASSIGNMENT.
*Worth: 50 points
*Made by: Samuel Georgeo (max11)
create
an in-memory SERIALLY linked-list database program which
displays a menu screen.
-------------------------------------------------------------------*/

#include <stdio.h>
#include <iostream>
#include "/var2/local/include/getch.h"
using namespace std ;
/*-----------------------------------------------------
* MAIN PROGRAM STARTS HERE
-----------------------------------------------------*/
int main(int argc, char *argv[1])
{
	char  b;
	while(1)
	{
		putchar('\n') ;
		puts("\t\te) Enter a new agent");
		puts("\t\tl) List agents in file");
		puts("\t\tn) Next Struct in List");
		puts("\t\tp) Prev Struct in List");
		puts("\t\tq) Quit program");

		if (phere)  // avoid segfault for nonexistant record
		phere->print_rec() ;

		putchar('\n') ;
		b = getch();
		switch(b)
		{
			case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1) [B];[/B]
					p [B]-[/B]> next = p [B]-[/B]> prev = p;
					edit_rec (p);
				} else {
					phere = p [B]-[/B]> prev;
					pnew = new prs;
					if (!pnew) exit(-1)[B];[/B]
					p [B]-[/B]> prev = pnew;
					pnew [B]-[/B]> next = p;
					phere [B]-[/B]> next =[B]???[/B];
				} // You missed this out..
				break;

			case 'l':
				puts("you typed l") ;
				break;
			case 'n':
				phere= phere->getNext() ;
				break;
			case 'p':
				phere= phere->getFrom();
				break;
			case 'q':
				puts("you typed q") ;
				return 0 ;
				break;
		};  // switch case b
	};
	deletelist (head);
}// main
commented: Well spotted :) I gave the more obvious problems +2

I am thanking all for the help. I appreciate it so much. I couldn't find a better teacher than you guys. With your advices and corrections, I still get thos errors??

error C2143: syntax error : missing ';' before '%'
include\xlocnum(1) : error C4430: missing type specifier - int assumed. Note: C++ does Fatal error C1004: unexpected end-of-file found

I am thanking all for the help. I appreciate it so much. I couldn't find a better teacher than you guys. With your advices and corrections, I still get thos errors??

error C2143: syntax error : missing ';' before '%'
include\xlocnum(1) : error C4430: missing type specifier - int assumed. Note: C++ does Fatal error C1004: unexpected end-of-file found

Look at williamhemswort 's post again (line 49). Did you add that ending bracket } ?

Look at williamhemswort 's post again (line 49). Did you add that ending bracket } ?

Yes... I did. Nothing is working. I am having a Programmer's Block :'(

then what errors are you getting..can you repost your edited code

then what errors are you getting..can you repost your edited code

/*------------------------------------------------------------------
* Assignment 7: FIRST LINKED LIST ASSIGNMENT.
*Worth: 50 points
*Made by: Samuel Georgeo (max11)
create
an in-memory SERIALLY linked-list database program which
displays a menu screen.
-------------------------------------------------------------------*/

#include <stdio.h>
#include <iostream>
#include "/var2/local/include/getch.h"
using namespace std ;
/*-----------------------------------------------------
* MAIN PROGRAM STARTS HERE
-----------------------------------------------------*/
int main(int argc, char *argv[1])
{
	char  b;
	while(1)
	{
		putchar('\n') ;
		puts("\t\te) Enter a new agent");
		puts("\t\tl) List agents in file");
		puts("\t\tn) Next Struct in List");
		puts("\t\tp) Prev Struct in List");
		puts("\t\tq) Quit program");

		if (phere)  // avoid segfault for nonexistant record
		phere->print_rec() ;

		putchar('\n') ;
		b = getch();
		switch(b)
		{
			case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p > next = p > prev = p;
					edit_rec (p);
				} else {
					phere = p > prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p > prev = pnew;
					pnew > next = p;
					phere > next = p;
				} 
				break;

			case 'l':
				puts("you typed l") ;
				break;
			case 'n':
				phere= phere->getNext() ;
				break;
			case 'p':
				phere= phere->getFrom();
				break;
			case 'q':
				puts("you typed q") ;
				return 0 ;
				break;
		};  // switch case b
	};
	deletelist (head);
}// main

you have not read through all the posts here.. i can see this piece of code was already corrected from this

case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p > next = p > prev = p;
					edit_rec (p);
				} else {
					phere = p > prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p > prev = pnew;
					pnew > next = p;
					phere > next = p;

to this

case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p  ->  next = p -> prev = p;
					edit_rec (p);
				} else {
					phere = p -> prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p -> prev = pnew;
					pnew -> next = p;
					phere -> next = p;

Note the changes in red. I have not corrected the code for it to work but I am just pointing out that maybe you have not done as suggested

error C2143: syntax error : missing ';' before '%'

There isn't a '%' in this program, this error is probably from the getch.h file. Please post the code as Ancient Dragon requested earlier.

you have not read through all the posts here.. i can see this piece of code was already corrected from this

case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p > next = p > prev = p;
					edit_rec (p);
				} else {
					phere = p > prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p > prev = pnew;
					pnew > next = p;
					phere > next = p;

to this

case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p  ->  next = p -> prev = p;
					edit_rec (p);
				} else {
					phere = p -> prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p -> prev = pnew;
					pnew -> next = p;
					phere -> next = p;

Note the changes in red. I have not corrected the code for it to work but I am just pointing out that maybe you have not done as suggested

Since joshmo pointed out my simple mistake... I changed but Visual Studio started to hate me because it threw me 55 errors on the complier. I edited the code asn it showed below:

/*------------------------------------------------------------------
* Assignment 7: FIRST LINKED LIST ASSIGNMENT.
*Worth: 50 points
*Made by: Samuel Georgeo (max11)
create
an in-memory SERIALLY linked-list database program which
displays a menu screen.
-------------------------------------------------------------------*/

#include <stdio.h>
#include <iostream>
#include "/var2/local/include/getch.h"
using namespace std ;
/*-----------------------------------------------------
* MAIN PROGRAM STARTS HERE
-----------------------------------------------------*/
int main(int argc, char *argv[1])
{
	char  b;
	while(1)
	{
		putchar('\n') ;
		puts("\t\te) Enter a new agent");
		puts("\t\tl) List agents in file");
		puts("\t\tn) Next Struct in List");
		puts("\t\tp) Prev Struct in List");
		puts("\t\tq) Quit program");

		if (phere)  // avoid segfault for nonexistant record
		phere->print_rec() ;

		putchar('\n') ;
		b = getch();
		switch(b)
		{
			case 'e':
				if(!p) {
					p = new prs;
					if (!p) exit(-1)
					p -> next = p -> prev = p;
					edit_rec (p);
				} else {
					phere = p -> prev;
					pnew = new prs;
					if (!pnew) exit(-1)
					p -> prev = pnew;
					pnew -> next = p;
					phere -> next = p;
				} 
				break;

			case 'l':
				puts("you typed l") ;
				break;
			case 'n':
				phere= phere-> getNext() ;
				break;
			case 'p':
				phere= phere-> getFrom();
				break;
			case 'q':
				puts("you typed q") ;
				return 0 ;
				break;
		};  // switch case b
	};
	deletelist (head);
}// main

I get the errors as the stated below

error C2143: syntax error : missing ';' before '/'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C3872: '0x4': this character is not allowed in an identifier
error C3872: '0x24': this character is not allowed in an identifier
error C2018: unknown character '0x4'
error C2018: unknown character '0x60'
error C2018: unknown character '0x1c'
error C2018: unknown character '0x1c'
error C2001: newline in constant
error C2018: unknown character '0x40'
error C2018: unknown character '0x2'
error C2018: unknown character '0x5'
error C2018: unknown character '0x4'
error C2018: unknown character '0x3'
error C2018: unknown character '0x10'
error C2018: unknown character '0x1'
error C2018: unknown character '0x7'
error C2018: unknown character '0x6'
error C2018: unknown character '0x7'
error C2018: unknown character '0x40'
error C2018: unknown character '0x5'
error C2018: unknown character '0x4'
error C2018: unknown character '0x1'
error C2018: unknown character '0x7f'
error C2018: unknown character '0x17'
error C2018: unknown character '0x16'
error C2018: unknown character '0x7'
error C2143: syntax error : missing ')' before '{'
error C2143: syntax error : missing ';' before '{'
error C2447: '{' : missing function header (old-style formal list?)
error C2018: unknown character '0xe'
error C2018: unknown character '0x1'
error C2018: unknown character '0x7f'
error C2018: unknown character '0x2'
error C2018: unknown character '0x8'
error C2018: unknown character '0x10'
error C2018: unknown character '0x3'
error C2018: unknown character '0x3'
error C2018: unknown character '0x2'
error C2018: unknown character '0x10'
error C2018: unknown character '0x3'
error C2018: unknown character '0x6'
error C2018: unknown character '0x5'
error C2059: syntax error : 'bad suffix on number'
error C2018: unknown character '0xe'
error C2018: unknown character '0x1'
error C2018: unknown character '0x2'
error C2018: unknown character '0x8'
error C2018: unknown character '0x7'
error C2018: unknown character '0x6'
error C2018: unknown character '0x5'
error C2018: unknown character '0x19'
error C2018: unknown character '0xf'
error C2018: unknown character '0x1'
fatal error C1004: unexpected end-of-file found

There are actually a couple of semicolons missing from Joshmo's correction, for starters you might change both if (!p) exit(-1) to if (!p) exit(-1) [B];[/B] and then recompile and post the new errors. Most probably you are receiving most of the errors due to the "/var2/local/include/getch.h", so you might post that file also. (I take that e.g. 'phere' and other related things are declared there(?))

There are actually a couple of semicolons missing from Joshmo's correction, for starters you might change both if (!p) exit(-1) to if (!p) exit(-1) [B];[/B] and then recompile and post the new errors. Most probably you are receiving most of the errors due to the "/var2/local/include/getch.h", so you might post that file also. (I take that e.g. 'phere' and other related things are declared there(?))

Thanks but the errors are still same. Even though the semicolon is missing from the prevous.. The most errors came from "unknown characters"

Thanks but the errors are still same. Even though the semicolon is missing from the prevous.. The most errors came from "unknown characters"

Well, given the code you've posted this far, makes it impossible to figure out further what goes wrong ... for one example, what is 'phere'? Is it something that you have in "getch.h"?

Well, given the code you've posted this far, makes it impossible to figure out further what goes wrong ... for one example, what is 'phere'? Is it something that you have in "getch.h"?

How exactly I can introduce "phere" in my code? I tried the "#include getch.h" but it won't help me at all

Why dont you post your "getch.h" file.

How exactly I can introduce "phere" in my code? I tried the "#include getch.h" but it won't help me at all

I assume that in some file you have for example something like

// struct or class named prs
struct prs
{
    // something here
};
// a function which takes a pointer to prs
void edit_rec (prs * p);

maybe 'phere' appears also there, so you might post that file (at least).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.