473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

how to use a label??

How to use a label in c?? also how to call???

Apr 18 '06 #1
4 39663
hisam wrote:
How to use a label in c?? also how to call???

Any C book will tell you how to do this. Maybe try Google if you do not
have a paper book.
Apr 18 '06 #2
hisam schrieb:
How to use a label in c?? also how to call???


From the C99 standard:

,-- 6.8.1 Labeled statements --
Syntax
1
labeled-statement:
identifier : statement
case constant-expression : statement
default : statement

Constraints
2 A case or default label shall appear only in a switch statement.
Further constraints on such labels are discussed under the switch
statement.
3 Label names shall be unique within a function.
Semantics
4 Any statement may be preceded by a prefix that declares an
identifier as a label name.
Labels in themselves do not alter the flow of control, which
continues unimpeded across them.
`----

Usage with goto: Labels have to precede a statement (not a
declaration) and are visible within a function, regardless of
nesting of block scopes.

Example [untested]:

int main (void)
{
int i;

loopinit:
i = 0;
loopcontinuation:
if (i < 10)
goto loopend;
{
/* Do something */
if (i==5)
goto loopupdate;
/* Do something else */
}
loopupdate:
i++;
goto loopcontinuation;
loopend:
;

return 0;
}

Obviously,
int main (void)
{
int i;

for (i = 0; i < 10; i++)
{
/* Do something */
if (i==5)
continue;
/* Do something else */
}

return 0;
}
is easier on the eye.

Case/default labels are visible only for the switch statement
they belong to. Untested example:

int main (void)
{
int i = 6, j = 7, k = 0;

switch (i) {
case 0:
j *= -1;
break;
case 6:
switch (j) {
case 0:
k = 7;
break;
case 7:
k = i*j;
break;
}
break;
default:
j = 23;
}
switch (k) {
case 7:
/* Whatever */
break;
case 42:
/* Yep */
break;
default:
/* Boring */
break;
}

return 0;
}
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Apr 18 '06 #3
hisam wrote:
How to use a label in c?? also how to call???

C has labels

ALabel:

C has goto

goto ALabel;

C does not have call it has functions. BASIC has call.

To invoke a function just use its name

AFunction();
Apr 19 '06 #4
On 18 Apr 2006 12:30:29 -0700, "hisam" <mh*********@gmail.com> wrote:
How to use a label in c?? also how to call???


Others have told you how to use a label. I'll tell you when to use
one: after at least a couple more years of C programming, when there's
no good alternative. In the meantime, read
http://www.acm.org/classics/oct95/

--
Al Balmer
Sun City, AZ
Apr 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xerxes | last post by:
Hi, can you tell me how I can make a <label> hidden? I have hidden the field after the label: var M_Hide = isNS4?'hide':'hidden'; var M_Show = isNS4?'show':'visible'; ..... <label...
3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
31
by: jcrouse | last post by:
Is there a quick and easy way to change the color of a label controls border from the default black to white? Thank you, John
2
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub ShowData(obj As Object, ea As EventArgs) lblDate.Text = DateTime.Now.ToString("d") lblDate.DataBind() End Sub </script> <form...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
1
by: Manoj Mittal | last post by:
I have created the Dynamic control in asp.net c# like for (int i = 1; i <= 5; i++) { Label label = new Label(); label.ID = "Label" + i; label.Text = "Label"+i; form1.Controls.Add(label); }
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-))...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.