This is a discussion on Is there Program Error within the C and C++ forums, part of the Programming Talk category; Recently I and my friend came across a small C program which I have given below: #include <stdio.h&...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Recently I and my friend came across a small C program which I have given below:
#include <stdio.h> main() { int test[10]; int b=5; int a= b++ + array[b]; } My friend told me the above program would give error. But I told the above program would work fine and the result of value b would be 6. Let us know who is correct. Will the program give error as my friend suggest? Kindly help us know about this. |
|
|||
|
I think you have by mistake made a typo error as array[b] instead of putting as test[b]. If t is test[b] in the statement as
int a= b++ + test[b]; Then you would have the value of b as 6 as you suggested. But if it is array[b] then it would give compile time error. |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 05-15-2004 07:00 AM |
| Apple II Csa2 FAQs: Error List, Part 8/25 | rubywand@swbell.net | Tech FAQ | 0 | 05-04-2004 10:01 AM |
| Linux Frequently Asked Questions with Answers (Part 6 of 6) | rkiesling@mainmatter.com | Tech FAQ | 0 | 05-03-2004 07:55 AM |
| Apple II Csa2 FAQs: Telecom Hardware & Transfers, Part 20/25 | rubywand@swbell.net | Tech FAQ | 0 | 04-04-2004 08:29 AM |