here is the question
1. read in a first name, last name and telephone number
and store these in the list.
2. a search function that reads in a first name and last
name and searches the list for the name and prints
the phone number if found.
and the is what i did -
#include <iostream>
-
#include <cstring>
-
using namespace std;
-
-
-
struct pn {
-
char fn[25];
-
char ln[25];
-
char pnbr[15];
-
struct pn *next;
-
};
-
-
int main()
-
{
-
char t1[64], t2[64],t3[64];
-
struct pn *start=NULL, *p1,*p2,p3;
-
-
-
while(1){
-
cin >> t1;
-
if (strcmp(t1,"//")==0)break;
-
cin >> t2 >> t3;
-
-
p1 = new struct pn;
-
if (p1 == NULL ) {
-
cout << "memory error\n";
-
return 1;
-
}
-
strcpy(p1 -> fn,t1);
-
strcpy (p1 -> ln,t2);
-
strcpy(p1 -> pnbr,t3);
-
p1->next = start;
-
start = p1;
-
}
-
-
while(1){
-
cin >> t1;
-
if ( strcmp(t1,"//")==0)break;
-
-
cin >> t2;
-
for (p1 = start; p1 != NULL; p1 = p1 -> next){
-
if ( strcmp(t1,p1 ->fn)==0)
-
(strcmp( t2,p1 ->ln)==0);
-
cout << "found b" << p1->pnbr << endl;
-
break;
-
}
-
-
-
{
-
if (p1== NULL) cout << "not found";
-
}
-
-
-
-
-
-
return 0;
-
-
}
-
}
-
so what my problem
there is no output
thanks
10 1031
You could not possibly have output. Your code is not compileable. Fix the syntax errors.
Fix your indentation. It's a mess. Poorly indented code means you can't read it properly, and you'll make mistakes in editing it.
Watch your struct syntax. This is C++, not C. Read a C++ book on struct syntax if you aren't sure.
thanks
so all my code is wrong!!!!!!!!!!!!!!!!!1
hi,
when does this code come out of the loop? -
while(1){
-
cin >> t1;
-
if (strcmp(t1,"//")==0)break;
-
cin >> t2 >> t3;
-
-
p1 = new struct pn;
-
if (p1 == NULL ) {
-
cout << "memory error\n";
-
return 1;
-
}
-
strcpy(p1 -> fn,t1);
-
strcpy (p1 -> ln,t2);
-
strcpy(p1 -> pnbr,t3);
-
p1->next = start;
-
start = p1;
-
}
Its been a while since i touched pointers, but dosent start always gets pointed to the newly created struct?
which means that when u create a new node, the previous one is lost as a memory leak and you have no access to it anymore?
please correct me if i am wrong
ok
can i just know what the output ganna be
(just the output, i dont want the code)))
thanks again
if you have written the code yourself, have you tried compiling it?
yeah i tried but the there is nothing
i don't want the program to work i just want to know how the program output should be . that's it.
thanks
Well, if the program doesn't work, then the output will be incorrect.
My guess is, you are looking for a cheap way out of doing an assignment. As you should know from reading our Posting Guidelines, we don't give away solutions to problems without the user having tried.
If you want the output of this program, you will have to correctly write the program first. Now, we are more than willing to help you - if you are willing to do some work and not demand the solution from us.
Ganon11
I understand that but I didn't say I want the answer I said i want to know how the out put should be like.
thanks again
There really doesn’t seem to be much to it. Then again, you’re the one with the question paper.
I would guess you have a menu system, someway of acknowledging or rejecting user input, and so on. It’s just simple console based output, so it’s not going to look like much more than ASCII...
thank you so much I'm working on it now.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Spamtrap |
last post by:
I only do occasional Perl programming and most things I write are
short processes. I have something I'm working on that is scanning a
text file with about 15 million lines and trying to extract...
|
by: aj902 |
last post by:
Hello ,
I am trying to create a program
where all detail,
http://www.albany.edu/~csi333/projects.htm
|
by: vgame64 |
last post by:
Hi, I have been struggling with writing a program for a few hours. The
requirements are that: """You will be writing a program which will
determine whether a date is valid in
terms of days in that...
|
by: robinsand |
last post by:
My apologies to those of you who are more advanced Visual C++ .NET
programmers, but I am working on a project for an MBA course that is
condensed into an eight-week schedule, and I need help...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: naknak4 |
last post by:
Introduction
This assignment requires you to develop solutions to the given problem
using several different approaches (which actually involves using three
different STL containers). You will...
|
by: naknak |
last post by:
Introduction
This assignment requires you to develop solutions to the given problem
using several different approaches (which actually involves using three
different STL containers). You will...
|
by: peterggmss |
last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for...
|
by: raghavshastri |
last post by:
You are to write a C++ program to perform a statistical analysis of the blobs in an image. The image will be a grayscale image in PGM format for simplicity.
Here is a sample PGM image with 10...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |