Teledyne-lecroy Protocol Analyzers File-Based Decoding User Manual Manuel d'utilisateur Page 30

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 82
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 29
Chapter 7: Statements File-based Decoding User Manual
24 LeCroy Corporation
7.6 return Statements
Every function returns a value, which is usually designated in a return statement. A
return statement returns the value of an expression to the calling environment. It uses
the following form:
return <expression>;
An example of a return statement and its calling environment is
str = FormatEx ( "%s", HiThere() );
...
HiThere()
{
return "Hi there";
}
The call to the function FormatEx causes the function HiThere() to be executed.
HiThere() returns the string “Hi there” as its value. This value is passed to the calling
environment (
FormatEx), causing “Hi there” to be assigned to str.
A return statement also causes a function to stop executing. Any statements that come
after the
return statement are ignored, because return transfers control of the
program back to the calling environment. As a result,
str = FormatEx ( "%s", HiThere() );
...
HiThere()
{
a = "Hi there";
return a;
b = "Goodbye";
return b;
}
results in only “Hi there” getting assigned to str. Because when return a; is
encountered, execution of the function terminates, and the second return statement
(
return b;) is never processed.
Vue de la page 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 81 82

Commentaires sur ces manuels

Pas de commentaire