I wrote that program from a book that my compile that program
correctly under C++ compiler but I got those errors for compiling
under unix !!
Errors-
--------
part10_iti_r01_ ch10_verbo_menu _driven_program s.c: In function `main':
part10_iti_r01_ ch10_verbo_menu _driven_program s.c:6: warning:
declaration of `argc' shadows a parameter
part10_iti_r01_ ch10_verbo_menu _driven_program s.c:7: warning:
declaration of `argv' shadows a parameter
part10_iti_r01_ ch10_verbo_menu _driven_program s.c:22: syntax error
before '{' token
Program-
--------
#include <stdio.h>
//part10_iti_r01_ ch10_verbo_menu _driven_program s.c
main (argc,argv)
{
int argc;
char *argv[50];
{
int option;
do
{
//Display menu
display_menu();
//Initite appropriate program or exit
if (option!=7) //exit
call_program(op tion,argv);
}
while (option!=7);
}
display_menu()
{
system("clear") ;
printf ("\n TV Rental system");
printf ("\n ----------------");
printf("\n\n 1 Set up new customer");
printf("\n\n 2 Change existing customer record");
printf("\n\n 3 Add new customer record");
printf("\n\n 4 Delete customer record");
printf("\n\n 5 Print customer bills");
printf("\n\n 6 display a customer record");
printf("\n\n 7 Exit");
}
user_selection( )
{
int opt;
printf("\n\n Enter required option number (1-7) ");
scanf("%d",&opt );
return(opt);
}
call_program(op t,argv)
int opt;
char *argv[];
{
switch(opt)
{
case 1: spawnvp(0,"a.ob j",argv);
delay();
break;
default:printf( "\nError");
delay();
}
}
delay()
{
int i;
for (i=0;i<=20000;+ +i);
} 27 3251
"hp******@yahoo .com" <eh***********@ yahoo.com> wrote in message
news:7e******** *************** ***@posting.goo gle.com... I wrote that program from a book that my compile that program correctly under C++ compiler but I got those errors for compiling under unix !!
Errors- -------- part10_iti_r01_ ch10_verbo_menu _driven_program s.c: In function `main': part10_iti_r01_ ch10_verbo_menu _driven_program s.c:6: warning: declaration of `argc' shadows a parameter part10_iti_r01_ ch10_verbo_menu _driven_program s.c:7: warning: declaration of `argv' shadows a parameter part10_iti_r01_ ch10_verbo_menu _driven_program s.c:22: syntax error before '{' token
Program- -------- #include <stdio.h> file://part10_iti_r01_ ch10_verbo_menu _driven_program s.c
main (argc,argv) { int argc; char *argv[50]; {
What language is this?? I can't imagine that this would compile under C++
or C. I think that you are trying to use old style function declarations
of the type:
foo(p1,p1)
int p1;
int p2;
{
...
}
You should change these to the newer style function declarations:
int foo(int p1,int p2)
{
...
}
So this would become:
int main(int argc, char ** argv)
{
int option;
....
}
int option; do { file://Display menu display_menu();
file://Initite appropriate program or exit if (option!=7) file://exit call_program(op tion,argv); } while (option!=7); } display_menu() { system("clear") ; printf ("\n TV Rental system"); printf ("\n ----------------"); printf("\n\n 1 Set up new customer"); printf("\n\n 2 Change existing customer record"); printf("\n\n 3 Add new customer record"); printf("\n\n 4 Delete customer record"); printf("\n\n 5 Print customer bills"); printf("\n\n 6 display a customer record"); printf("\n\n 7 Exit"); }
user_selection( ) { int opt; printf("\n\n Enter required option number (1-7) "); scanf("%d",&opt ); return(opt); }
call_program(op t,argv) int opt; char *argv[]; { switch(opt) { case 1: spawnvp(0,"a.ob j",argv); delay(); break;
default:printf( "\nError"); delay(); } }
delay() { int i; for (i=0;i<=20000;+ +i); }
Same for call_program:
int call_program(in t opt,char ** argv)
{
...
}
Sean eh***********@y ahoo.com (hp******@yahoo .com) writes: I wrote that program from a book that my compile that program correctly under C++ compiler but I got those errors for compiling under unix !!
Errors- -------- part10_iti_r01_ ch10_verbo_menu _driven_program s.c: In function `main': part10_iti_r01_ ch10_verbo_menu _driven_program s.c:6: warning: declaration of `argc' shadows a parameter part10_iti_r01_ ch10_verbo_menu _driven_program s.c:7: warning: declaration of `argv' shadows a parameter part10_iti_r01_ ch10_verbo_menu _driven_program s.c:22: syntax error before '{' token
Program- -------- #include <stdio.h> //part10_iti_r01_ ch10_verbo_menu _driven_program s.c
main (argc,argv) {
Get rid of that brace...
int argc; char *argv[50];
.... and drop the old K&R style.
{ int option; do { //Display menu display_menu();
//Initite appropriate program or exit if (option!=7) //exit call_program(op tion,argv); } while (option!=7); } display_menu() { system("clear") ; printf ("\n TV Rental system"); printf ("\n ----------------"); printf("\n\n 1 Set up new customer"); printf("\n\n 2 Change existing customer record"); printf("\n\n 3 Add new customer record"); printf("\n\n 4 Delete customer record"); printf("\n\n 5 Print customer bills"); printf("\n\n 6 display a customer record"); printf("\n\n 7 Exit"); }
user_selection( ) { int opt; printf("\n\n Enter required option number (1-7) "); scanf("%d",&opt ); return(opt); }
call_program(op t,argv) int opt; char *argv[]; { switch(opt) { case 1: spawnvp(0,"a.ob j",argv);
What does spawnvp do?
delay(); break;
default:printf( "\nError"); delay(); } }
delay() { int i; for (i=0;i<=20000;+ +i); }
How ancient is this. That loop takes no time at all to run here.
--
Måns Rullgård mr*@kth.se eh***********@y ahoo.com (hp******@yahoo .com) writes in comp.unix.solar is:
|I wrote that program from a book that my compile that program
|correctly under C++ compiler but I got those errors for compiling
|under unix !!
|
|Errors-
|--------
|part10_iti_r01 _ch10_verbo_men u_driven_progra ms.c: In function `main':
|part10_iti_r01 _ch10_verbo_men u_driven_progra ms.c:6: warning:
|declaration of `argc' shadows a parameter
|part10_iti_r01 _ch10_verbo_men u_driven_progra ms.c:7: warning:
|declaration of `argv' shadows a parameter
|part10_iti_r01 _ch10_verbo_men u_driven_progra ms.c:22: syntax error
|before '{' token
|main (argc,argv)
|{
|int argc;
|char *argv[50];
|{
This should be
int main (int argc, char *argv[])
{
You've got too many {'s along with obsolete syntax. (As has been
mentioned before, it appears whatever book you're using should be
burned.)
--
_______________ _______________ _______________ _______________ ____________
Alan Coopersmith al***@alum.calb erkeley.org http://www.CSUA.Berkeley.EDU/~alanc/ aka: Al************* *@Sun.COM
Working for, but definitely not speaking for, Sun Microsystems, Inc.
In comp.unix.progr ammer Måns Rullgård <mr*@kth.se> wrote: eh***********@y ahoo.com (hp******@yahoo .com) writes:
I wrote that program from a book that my compile that program correctly under C++ compiler but I got those errors for compiling under unix !!
delay() { int i; for (i=0;i<=20000;+ +i); }
How ancient is this. That loop takes no time at all to run here.
And probably every self-respecting compiler will optimize out that
loop (i.e. throw it away because there's no result that's ever going
to be used) unless you declare 'i' as volatile. And even then the
time that delay will take is probably absolutely negligible. With
any modern computer the maximum delay you'll be getting is probably
somewhere in the order of a micro-second.
But how you got to compile this program with a C++ compiler is
completely beyond me. And even if you did, how is 'option' ever
to be changed? Shouldn'd there be a call of the user_selection( )
function somewhere in main()s loop? And what's the switch in
call_program() good for? Is only the first menu option usable?
Or have you accidentally skipped a few pages in the book while
copying the program? I guess the best you can do is throw that
book away, all you can learn from it is either completely out-
dated or plain wrong.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.physik.fu-berlin.de/~toerring hp******@yahoo. com wrote: I wrote that program from a book that my compile that program correctly under C++ compiler
Somehow, I doubt that.
but I got those errors for compiling under unix !!
The code you transcribed here is /so/ wrong.
You are compiling bad K&R (pre-ANSI) C with ANSI C99 / C++ comments using a
C++ compiler, and expecting it to compile properly and execute.
1) This is not C++, so stop using a C++ compiler on it
2) This is not C99, so lose the C++style comments
3) There are logic errors in your code. Fix them
(for instance, you never assign a value to your 'options' variable,
you test the 'options' variable for a value that can never occur,
etc.)
4) You use platform-specific functions; either lose them or submit your
corrected code to a forum that has knowledge of them.
--
Lew Pitcher, IT Consultant, Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed here are my own, not my employer's)
On Wed, 28 Jan 2004, Alan Coopersmith wrote: You've got too many {'s along with obsolete syntax. (As has been mentioned before, it appears whatever book you're using should be burned.)
Agreed. To the OP: Don't bother with "C for Dummies" either,
or any other book that thinks that "void main (...)" is valid.
I'm reading in this in comp.unix.solar is: I humbly submit that
my forthcoming book, Solaris Systems Prorgamming, should be on
your shopping list (in addition to a good C tutorial - my book
assumes some C knowledge).
One more tip: try to ask your questions in a more focussed group
of newsgroups.
--
Rich Teer, SCNA, SCSA
President,
Rite Online Inc.
Voice: +1 (250) 979-1638
URL: http://www.rite-online.net
Lew Pitcher wrote: You are compiling bad K&R (pre-ANSI) C with ANSI C99 / C++ comments using a C++ compiler, and expecting it to compile properly and execute.
It's not even old-style C, because he has an opening brace before the
argc and argv declarations, which then turns them into local variables
(hence the error message).
The OP needs to go back to square one, get a good book and start again
with a few simple programs.
Brian Rodenborn hp******@yahoo. com wrote: I wrote that program from a book that my compile that program correctly under C++ compiler
No, it didn't. Some other program did, probably one without the trivial
error below.
but I got those errors for compiling under unix !!
Unix is irrelevant. Your code is broken.
#include <stdio.h> //part10_iti_r01_ ch10_verbo_menu _driven_program s.c
main (argc,argv) { int argc; char *argv[50]; {
You are incorrectly using an outmoded style of specifying the arguments. If
you insist on using this style, it should be
int main(argc, argv)
int argc;
char *argv[];
{
Notice that the extra brace '{' is missing and the bogus '50' is missing.
The modern way to do this, if you consider the last 15 years to to be the
modern era, is
int main(int argc, char *argv[])
{
Since it is normal etiquette to check the FAQs and follow the traffic on a
newsgroup before posting, I suspect that you really knew these things. It
is impossible to read the FAQs for and follow all of comp.lang.c,
comp.unix.solar is, comp.unix.progr ammer, gnu.g++.help, and gnu.gcc.help
without seeing these simple things done correctly.
--
Martin Ambuhl
Martin Ambuhl <ma*****@earthl ink.net> writes: hp******@yahoo. com wrote:
I wrote that program from a book that my compile that program correctly under C++ compiler
[snip]
You are incorrectly using an outmoded style of specifying the arguments. If you insist on using this style, it should be
int main(argc, argv) int argc; char *argv[]; {
Actually, even that one won't work with C++ (remember, OP is using a C++
compiler).
E.g. the following program (saved in /tmp/p.cc file)
int main(argc, argv)
int argc;
char *argv[];
{
return 0;
}
produces the following errors:
% g++ -c /tmp/p.cc
/tmp/p.cc:1: error: `argc' was not declared in this scope
/tmp/p.cc:1: error: `argv' was not declared in this scope
/tmp/p.cc:2: error: initializer list being treated as compound expression
/tmp/p.cc:2: error: syntax error before `int'
/tmp/p.cc:3: error: storage size of `argv' isn't known
/tmp/p.cc:3: error: storage size of `argv' isn't known
/tmp/p.cc:4: error: parse error before `{' token
Bye, Dragan
--
Dragan Cvetkovic,
To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
!!! Sender/From address is bogus. Use reply-to one !!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: post400 |
last post by:
Hi,
there is another famous book 'Writing solid code' but does it apply to
Python ? Or it's usable only by Microsoft C programmers ? The author
seems to be an ex-Microsoft guy !
Thanks ,
post400
|
by: Philipp |
last post by:
Hello,
I would like to print (cout) the binary representation of a double.
ie the values of the bytes 1-8.
A typical output would be something like (in hex)
ff af 12 d3 ab 9f 3c 00
Is there a function which does this or anything approaching?
I read that on win32 the representation of 8byte double is
byte1 byte2 byte3 byte4 byte8
|
by: hpy_awad |
last post by:
I am writing stings ((*cust).name),((*cust).address)to a file using
fgets but rabish is being wrote to that file ? Look to my source
please and help me finding the reason why this rabish is being
written.
/* Book name :
File name : E:\programs\cpp\iti01\ch10\ex09_5p1.cpp
Program discription: Adding name,Address to customer_record SETUP
PROGRAM
|
by: 100 |
last post by:
Has anybody read Steve Maguire's book "Writing solid code"?
Do you think that the ideas in this book are not applicable in c# language?
Does anybody find
if(2 == i)
istead of
if(i == 2)
as unnetural and does it lead to more bugs in the code because of it makes
programms hard to read.
And my last question is: "Do you think that using boolean expressions
|
by: Nathan Sokalski |
last post by:
I am an ASP.NET developer who would like to start learning about writing
ASP.NET custom controls using VB.NET. I already have a reasonable amount of
knowledge with making ASP.NET pages, and am looking for a book specifically
on writing controls. Here are some things I would like the book to talk
about and my preferences as to how I would like it to be shown/explained:
1. I want it to use VB.NET for the examples, since that is what I write...
| |
by: JoeC |
last post by:
I am working on another game project and it is comming along. It is an
improvment over a previous version I wrote. I am trying to write
better programs and often wonder how to get better at programming. I
tend to learn what is useful and gets the job done. I am always
curious if there is some techique I don't know. I read books and study
as well as write programs. My goal is to some day be able to get a job
programming. I have a...
|
by: Hypnotik |
last post by:
Hello everyone. I'm working on a program which uses a class (Shelf) and a struct (Book). In the main program we declare an array (Library) which is of type shelf. The program takes in various info about books (author, title, isbn, etc) and then allows you to search for books starting with a certain letter, and in turn displays those books and the info on them.
At this point I can enter the info, and display the info for 1 book. I'm confused...
|
by: Marin Brkic |
last post by:
Hello all,
please, let me apologize in advance. English is not my first language
(not even my second one), so excuse any errors with which I'm about to
embarass myself in front of the general public. Second, I'm relatively
new to python, so sorry if this seems like a stupid question.
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |