lesson 10 proto c
[[lesson_10_proto_c]] last edit on Aug 18, 2005 6:12 AM by rescued_by_c

[user02@FC4 Lesson10]$ cat -n proto.c
   1  #include <stdio.h>
   2
   3  float average_value(int, int);  // Function prototype
   4
   5  int main(void)
   6  {
   7     printf("The average of 2000 and 2 is %f\n", average_value(2000, 2));
   8
   9     return 0;
  10  }
  11
  12  float average_value(int a, int b)
  13  {
  14     return((a + b) / 2.0);
  15  }
[user02@FC4 Lesson10]$ gcc -o proto proto.c
[user02@FC4 Lesson10]$ ./proto
The average of 2000 and 2 is 1001.000000
[user02@FC4 Lesson10]$



[user02@FC4 Lesson10]$ cat -n proto2.c
   1  #include <stdio.h>
   2
   3  //float average_value(int, int);  // Function prototype
   4
   5  int main(void)
   6  {
   7     printf("The average of 2000 and 2 is %f\n", average_value(2000, 2));
   8
   9     return 0;
  10  }
  11
  12  float average_value(int a, int b)
  13  {
  14     return((a + b) / 2.0);
  15  }
[user02@FC4 Lesson10]$ gcc -o proto2 proto2.c
proto2.c:13: error: conflicting types for ?eaverage_value?f
proto2.c:7: error: previous implicit declaration of ?eaverage_value?f was here
[user02@FC4 Lesson10]$ ./proto2
-bash: ./proto2: No such file or directory
[user02@FC4 Lesson10]$