main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0; //line 1
}
1. Can I know why using return causes an illegal syntax...I guess it
has something to do with command line arguments..
2. can anyone explain the line 1?? its a bit confusing.... 12 2073 ch*******@yahoo.com wrote: main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; //line 1 }
1. Can I know why using return causes an illegal syntax...I guess it has something to do with command line arguments.. 2. can anyone explain the line 1?? its a bit confusing....
1. No, it's because `return' is a statement, not an expression.
2. Simple. Syntax error. Next?
--ag
--
Artie Gold -- Austin, Texas http://goldsays.blogspot.com http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
I meant what does first part of the statement (main && argc) ?
main(argc-1, NULL) : return 0;
does...IGNORE THE PRESENCE OF return...
On 17 Jan 2006 07:15:34 -0800, in comp.lang.c , "ch*******@yahoo.com"
<ch*******@yahoo.com> wrote: main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; //line 1 }
1. Can I know why using return causes an illegal syntax...
The operands of the ternary operator must be of the same type, eg both
numeric, both the same struct type, both pointers to the same type,
both void, etc etc. "return 0" has no type and is not the same as the
type of main() which is int.
The correct way to write this (which is an example of a recursive
main, and illegal in C++ by the way) ) is
return (main && argc) ? main(argc-1, NULL) : 0;
has something to do with command line arguments.. 2. can anyone explain the line 1?? its a bit confusing....
Where do you get this rubbish? This is the third total nonsense bit
of code you've posted. What are you trying to do?
Also, when posting to CLC, you should post snippets which #include any
relevant headers. In this case, you need something to define NULL.
Mark McIntyre
--
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Hey brother...chill off...All I am trying to do is learn the way you
experts think....Is it bad??
<ch*******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... Hey brother...chill off...All I am trying to do is learn the way you experts think....
What the experts think is that you need to read
some C textbooks and learn how the language works
instead of guessing.
Is it bad??
Yes, I think your apparent method of learning C is
quite bad.
Also note that it's not usually a good idea to
insult those who can help you.
Mark might not be the best expert here (I doubt he'd
make that claim), but imo he does have considerable
C knowledge and can offer much help (if you don't
drive him away, that is).
-Mike ch*******@yahoo.com schrieb: main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; //line 1 }
1. Can I know why using return causes an illegal syntax...
Yes you can. Just learn C syntax.
2. can anyone explain the line 1?? its a bit confusing....
Since it's not C, there is nothing to explain.
Mark McIntyre wrote: On 17 Jan 2006 07:15:34 -0800, in comp.lang.c , "ch*******@yahoo.com" <ch*******@yahoo.com> wrote:
main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; //line 1 }
1. Can I know why using return causes an illegal syntax... The operands of the ternary operator must be of the same type, eg both numeric, both the same struct type, both pointers to the same type, both void, etc etc.
Assuming that you mean the two rightmost operands,
if either of the two right most operands
is a null pointer constant, or pointer to type void,
then the other operand may be a pointer to a different type.
Where do you get this rubbish? This is the third total nonsense bit of code you've posted.
I've noticed that too.
--
pete
On 17 Jan 2006 07:43:45 -0800, in comp.lang.c , "ch*******@yahoo.com"
<ch*******@yahoo.com> wrote: I meant what does first part of the statement (main && argc) ? main(argc-1, NULL) : return 0;
its a ternary operator, equivalent to if... then... else... endif
if (main && argc)
main(argc-1, NULL):
else
return 0;
except that it has different syntax rules.
does...IGNORE THE PRESENCE OF return...
but you did ask about that bit
Mark McIntyre
--
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
On 17 Jan 2006 08:16:12 -0800, in comp.lang.c , "ch*******@yahoo.com"
<ch*******@yahoo.com> wrote: Hey brother...chill off...
Sure, if you promise to start learning properly and use a book. You
cannot learn programming from usenet.
All I am trying to do is learn the way you experts think....Is it bad??
Learning the way we think, by posting garbage posts?
Well, you're going to achieve that, because most of us are probably
now thinking "this chump1708 is a complete idiot".
Mark McIntyre
--
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
On Tue, 17 Jan 2006 16:25:14 GMT, in comp.lang.c , "Mike Wahler"
<mk******@mkwahler.net> wrote: Mark might not be the best expert here (I doubt he'd make that claim),
For the record, theres absolutely no way I'd do that. :-)
Mark McIntyre
--
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mark McIntyre wrote: On Tue, 17 Jan 2006 16:25:14 GMT, in comp.lang.c , "Mike Wahler" <mk******@mkwahler.net> wrote:
Mark might not be the best expert here (I doubt he'd make that claim),
For the record, theres absolutely no way I'd do that. :-)
Mark McIntyre
For the record, this Mark wouldn't either. :-)
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it. ch*******@yahoo.com wrote: Hey brother...chill off...All I am trying to do is learn the way you experts think....Is it bad??
Now this sort of rudeness is what will get you plonked.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve |
last post by:
Hello (and a happy new year)
I'm quite new to C++ and have to programm something for school and can't
get my head around
a couple of things, but at the moment this one is the most important for...
|
by: Michael Lopez |
last post by:
I've written a small web service in c# that takes in a plaintext string,
encrypts it, then returns the encrypted string. Some of the characters
returned by encryption are illegal xml characters and...
|
by: deko |
last post by:
Is there a way to check user input for illegal characters?
For example, a user enters something into a text box and clicks OK.
At that point I'd like to run code such as this:
illegal =...
|
by: Greenhorn |
last post by:
Hi,
when a function doesn't specify a return type ,value what value is
returned. In the below programme, the function sample()is returning the
value passed to 'k'.
sample(int);
main()
{
int...
|
by: Alfonso Morra |
last post by:
Hi I'm compiling some code and need to generate some random numbers. To
save time, I decided to use the srand, rand and time functions.
My code worked (atleast built fine) until I added time.h,...
|
by: Roy Smith |
last post by:
The following code appears to be illegal:
while ((int c = getchar()) != EOF) {
putchar (c);
}
I tried it on two different compilers (Sun workshop and gcc), and both
give some variation on...
|
by: illegal.prime |
last post by:
Hi all, I've got a client/server application and just wanted to ensure
that this is expected behavior. I recently set the following
configuration in Visual Studio:
Debug->Exceptions->Break Into...
|
by: news.pace.co.uk |
last post by:
Is the following legal C:
count++++;
Although I would expect to be shot for using such dodgy syntax, the question
is, is it legal syntax?
I was recently led to belive this should compile but...
|
by: sanjay.vasudevan |
last post by:
Why are the following declarations invalid in C?
int f();
int f();
It would be great if anyone could also explain the design decision
for such a language restricton.
Regards,
Sanjay
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
| |