#include <stdio.h>
int
main(void)
{
int s[3] = { 1, (3,2), (6, 5, 4)};
printf ("%d %d %d", s[0], s[1], s[2]);
}
~
~
>a.out
1 2 4
this means the last one within the parenthesis mark will works ,
what about others ?
what happened and why .
I want to know ...
it's a part of language or depend on implement ? 3 1311
anson said:
#include <stdio.h>
int
main(void)
{
int s[3] = { 1, (3,2), (6, 5, 4)};
printf ("%d %d %d", s[0], s[1], s[2]);
}
~
~
>>a.out
1 2 4
this means the last one within the parenthesis mark will works ,
what about others ?
what happened and why .
I want to know ...
it's a part of language or depend on implement ?
See page 62 of Kernighan and Ritchie's "The C Programming Language", 2nd
edition.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
In article <11**********************@o11g2000prd.googlegroups .com>,
anson <kz****@gmail.comwrote:
>#include <stdio.h>
>int main(void)
>{ int s[3] = { 1, (3,2), (6, 5, 4)};
>printf ("%d %d %d", s[0], s[1], s[2]);
>}
>>a.out
1 2 4
>this means the last one within the parenthesis mark will works , what about others ? what happened and why .
You used the "comma" operator, which evaluates each expression
in turn discarding each value except the last.
--
Prototypes are supertypes of their clones. -- maplesoft
On Fri, 13 Jul 2007 06:48:02 -0000, anson <kz****@gmail.comwrote in
comp.lang.c:
#include <stdio.h>
int
main(void)
{
int s[3] = { 1, (3,2), (6, 5, 4)};
printf ("%d %d %d", s[0], s[1], s[2]);
}
~
~
a.out
1 2 4
this means the last one within the parenthesis mark will works ,
what about others ?
what happened and why .
I want to know ...
it's a part of language or depend on implement ?
Actually this code is not valid C under versions of the C standard
earlier than 1999. It is valid under C99 and later, but it would not
be if the array 's' was defined with static storage duration.
All objects with static storage duration under all versions of the C
standard, and all aggregate objects prior to C99, must be initialized
with constant expressions. And the comma operator is not allowed in
constant expressions.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark A Framness |
last post by:
Greetings,
I am working on a project and we need to write a conversion script to
initialize a new field on a table. The number of records on this table
is on the order of millions so routine...
|
by: Mark Hannon |
last post by:
I am trying to initialize an array only once so it can be seen & used by
any functions that need it. As I understand it, if a variable is
declared by itself outside of any functions, its scope is...
|
by: dam_fool_2003 |
last post by:
Hai,
I studied that the array size is fixed. But I come across a word
called "variable length array". Is it possible to change the array
size? So I tried the following:
#include<stdio.h>...
|
by: Rano |
last post by:
/*
Hello,
I've got some troubles with a stupid program...
In fact, I just start with the C language and sometime
I don't understand how I really have to use malloc.
I've readden the FAQ...
|
by: Sharon |
last post by:
I have a delegate definition:
public delegate void SomeEventHandler(object obj);
To make an instance of it it’s easy:
public class myClass {
public event SomeEventHandler handler;
}
But,...
|
by: mark |
last post by:
When I declare an array as double(,) then try to use it I get an error:
"Object reference not set to an instance of an object."
I have found that I can redim the array and all is well. Is my...
|
by: mark |
last post by:
(windows app not web)
I have a procedure to populate a given datagrid (Datagrid1) with a dataset
from an indexed data connection. It works:
Globals: Dim FileName1 As String
Dim DS As...
|
by: Ying |
last post by:
I have problems to access a member in an array of pointers to structure.
I declare the following structure
struct {
char name;
float mark;
}*rec;
I would like to put data to rec. ...
|
by: Ming |
last post by:
for the following code, why it uses $method = 'examples.getStateName';
instead of $method = 'getStateName'; or $method =
'examples.getStateName()'
What does "example" here mean? Thanks
<?php...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: 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...
| |