error C2447: missing function header (old-style formal list?), what does this mean?!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #1
Dec 16th, 2004
I am writing a program using a linked list and I am almost to the point where I can compile and run it but I keep on getting this error message: error C2447: missing function header (old-style formal list?). What does it mean? I looked through the code but I cannot find anything wrong with it. Here is the code:

  1. #include<iostream.h>
  2.  
  3. struct temperature_node
  4. {
  5. int day;
  6. float temperature;
  7. temperature_node *next;
  8. };
  9.  
  10. temperature_node *head_ptr;
  11. temperature_node *current_ptr;
  12.  
  13. int get_temp(int days, float &temp);
  14. void show_temps();
  15. void remove_temps();
  16. void add_temp(int days, float temp);
  17. void move_c_to_end();
  18.  
  19. int main();
  20. {
  21. int days;
  22. float temp;
  23.  
  24. if(get_temp(days, temp))
  25. {
  26. head_ptr = new temperature_node;
  27. head_ptr->day = days;
  28. head_ptr->temperature = temp;
  29. head_ptr->next = NULL;
  30. while(get_temp(days, temp))
  31. {
  32. add_temp(days, temp);
  33. }
  34. show_temps();
  35. remove_temps();
  36. }
  37. return 0;
  38. }
  39.  
  40. int get_temp(int days, float &temp)
  41. {
  42. int keep_data = 1;
  43.  
  44. cout << "enter the days for which you have data ";
  45. cin >> days;
  46. if(days != 0)
  47. {
  48. cout << "enter the temperature ";
  49. cin >> temp;
  50. }
  51. else
  52. {
  53. keep_data = 0;
  54. }
  55. return(keep_data);
  56. }
  57.  
  58. void add_temp(int days, float temp)
  59. {
  60. temperature_node *new_rec_ptr;
  61. new_rec_ptr = new temperature_node;
  62.  
  63. new_rec_ptr->day = days;
  64. new_rec_ptr->temperature = temp;
  65. new_rec_ptr->next = NULL;
  66.  
  67. move_c_to_end();
  68. current_ptr->next = new_rec_ptr;
  69. }
  70.  
  71. void move_c_to_end()
  72. {
  73. current_ptr = head_ptr;
  74.  
  75. while(current_ptr->next != NULL)
  76. {
  77. current_ptr = current_ptr->next;
  78. }
  79. }
  80.  
  81. void show_temps()
  82. {
  83. current_ptr = head_ptr;
  84.  
  85. do
  86. {
  87. cout << current_ptr->day << endl;
  88. cout << current_ptr->temperature << endl;
  89. } while(current_ptr != NULL);
  90. }
  91.  
  92. void remove_temps()
  93. {
  94. temperature_node *temporary_ptr;
  95.  
  96. current_ptr = head_ptr;
  97.  
  98. do
  99. {
  100. temporary_ptr = current_ptr->next;
  101. delete current_ptr;
  102. current_ptr = temporary_ptr;
  103. }while(temporary_ptr != NULL);
  104. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 24
Reputation: yb1pls is an unknown quantity at this point 
Solved Threads: 1
yb1pls yb1pls is offline Offline
Newbie Poster

Re: error C2447: missing function header (old-style formal list?), what does this mea

 
0
  #2
Dec 16th, 2004
http://www.freewebs.com/yb2pls/index.htm

  1. #include<iostream.h>
  2.  
  3. struct temperature_node
  4. {
  5. int day;
  6. float temperature;
  7. temperature_node *next;
  8. };
  9.  
  10. temperature_node *head_ptr;
  11. temperature_node *current_ptr;
  12.  
  13. int get_temp(int days, float &temp);
  14. void show_temps();
  15. void remove_temps();
  16. void add_temp(int days, float temp);
  17. void move_c_to_end();
  18.  
  19. int main()
  20. {
  21. int days;
  22. float temp;
  23.  
  24. if(get_temp(days, temp))
  25. {
  26. head_ptr = new temperature_node;
  27. head_ptr->day = days;
  28. head_ptr->temperature = temp;
  29. head_ptr->next = NULL;
  30. while(get_temp(days, temp))
  31. {
  32. add_temp(days, temp);
  33. }
  34. show_temps();
  35. remove_temps();
  36. }
  37. return 0;
  38. }
  39.  
  40. int get_temp(int days, float &temp)
  41. {
  42. int keep_data = 1;
  43.  
  44. cout << "enter the days for which you have data ";
  45. cin >> days;
  46. if(days != 0)
  47. {
  48. cout << "enter the temperature ";
  49. cin >> temp;
  50. }
  51. else
  52. {
  53. keep_data = 0;
  54. }
  55. return(keep_data);
  56. }
  57.  
  58. void add_temp(int days, float temp)
  59. {
  60. temperature_node *new_rec_ptr;
  61. new_rec_ptr = new temperature_node;
  62.  
  63. new_rec_ptr->day = days;
  64. new_rec_ptr->temperature = temp;
  65. new_rec_ptr->next = NULL;
  66.  
  67. move_c_to_end();
  68. current_ptr->next = new_rec_ptr;
  69. }
  70.  
  71. void move_c_to_end()
  72. {
  73. current_ptr = head_ptr;
  74.  
  75. while(current_ptr->next != NULL)
  76. {
  77. current_ptr = current_ptr->next;
  78. }
  79. }
  80.  
  81. void show_temps()
  82. {
  83. current_ptr = head_ptr;
  84.  
  85. do
  86. {
  87. cout << current_ptr->day << endl;
  88. cout << current_ptr->temperature << endl;
  89. } while(current_ptr != NULL);
  90. }
  91.  
  92. void remove_temps()
  93. {
  94. temperature_node *temporary_ptr;
  95.  
  96. current_ptr = head_ptr;
  97.  
  98. do
  99. {
  100. temporary_ptr = current_ptr->next;
  101. delete current_ptr;
  102. current_ptr = temporary_ptr;
  103. }while(temporary_ptr != NULL);
  104. }

view my site http://www.freewebs.com/yb2pls/index.htm
and sign the guest book
Last edited by alc6379; Dec 17th, 2004 at 11:17 am. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,341
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 237
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: error C2447: missing function header (old-style formal list?), what does this mea

 
0
  #3
Dec 16th, 2004
Originally Posted by the b
I am writing a program using a linked list and I am almost to the point where I can compile and run it but I keep on getting this error message: error C2447: missing function header (old-style formal list?). What does it mean? I looked through the code but I cannot find anything wrong with it.
Notice the misplaced semicolon.
int main();
{
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #4
Dec 16th, 2004
I have a code snippet about singly / doubly linked lists if you run into any more trouble. Watch out for <iostream.h>, it should be 'updated' to

  1. #include <iostream>
  2. using namespace std;

as ive heard not all compilers / OS whatever support <iostream.h> anymore as it is non standardised!
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #5
Dec 17th, 2004
Ok, I have made a few modifications and the program actually runs; but only to a certain point. Just so you have an idea, this program is supposed to consist of asking the user for the number of days that he\she has temperatures for and putting them in a linked list. when I display them at the end of the program the average temperature is suposed to be calculated also. I do not have anything that calculates the average as of yet but I'm not to worried. The problem I seem to be having now is that nodes are not being added. I think it is because of something in the get_temp function. any help is greatly appreciated. Here is the code:

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct temperature_node
  5. {
  6. int day;
  7. float temperature;
  8. temperature_node *next;
  9. };
  10.  
  11. temperature_node *head_ptr;
  12. temperature_node *current_ptr;
  13.  
  14. int day_counter = 0;
  15.  
  16. int get_temp(int days, float &temp);
  17. void show_temps();
  18. void remove_temps();
  19. void add_temp(int days, float temp);
  20. void move_c_to_end();
  21.  
  22. int main()
  23. {
  24. int days = 0;
  25. float temp;
  26.  
  27. if(get_temp(days, temp))
  28. {
  29. head_ptr = new temperature_node;
  30. head_ptr->day = days;
  31. head_ptr->temperature = temp;
  32. head_ptr->next = NULL;
  33. while(get_temp(days, temp))
  34. {
  35. add_temp(days, temp);
  36. }
  37. show_temps();
  38. remove_temps();
  39. }
  40. return 0;
  41. }
  42.  
  43. int get_temp(int days, float &temp)
  44. {
  45. int keep_data = 1;
  46.  
  47. if(days <= 0)
  48. {
  49. cout << "enter the number of days for which you have temperatures ";
  50. cin >> days;
  51. }
  52.  
  53. while(day_counter != days)
  54. {
  55. cout << "Enter temperature for day " << day_counter + 1 << endl;
  56. cin >> temp;
  57. day_counter++;
  58. }
  59.  
  60. if(day_counter == days)
  61. {
  62. keep_data = 0;
  63. }
  64.  
  65. return(keep_data);
  66. }
  67.  
  68. void add_temp(int days, float temp)
  69. {
  70. temperature_node *new_rec_ptr;
  71. new_rec_ptr = new temperature_node;
  72.  
  73. new_rec_ptr->day = days;
  74. new_rec_ptr->temperature = temp;
  75. new_rec_ptr->next = NULL;
  76.  
  77. move_c_to_end();
  78. current_ptr->next = new_rec_ptr;
  79. }
  80.  
  81. void move_c_to_end()
  82. {
  83. current_ptr = head_ptr;
  84.  
  85. while(current_ptr->next != NULL)
  86. {
  87. current_ptr = current_ptr->next;
  88. }
  89. }
  90.  
  91. void show_temps()
  92. {
  93. current_ptr = head_ptr;
  94.  
  95. do
  96. {
  97. cout << current_ptr->day << endl;
  98. cout << current_ptr->temperature << endl;
  99. } while(current_ptr != NULL);
  100. }
  101.  
  102. void remove_temps()
  103. {
  104. temperature_node *temporary_ptr;
  105.  
  106. current_ptr = head_ptr;
  107.  
  108. do
  109. {
  110. temporary_ptr = current_ptr->next;
  111. delete current_ptr;
  112. current_ptr = temporary_ptr;
  113. }while(temporary_ptr != NULL);
  114. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #6
Dec 18th, 2004
this program is supposed to consist of asking the user for the number of days that he\she has temperatures for and putting them in a linked list.
Is this for an assignment?? otherwise if you are ASKING for the number of days why not declare an array with the given size:

  1. data_type *data; // data_type is your data type (char/int/long ect....)
  2.  
  3. data = (data_type*)new data_type[size]; // size is the number of elements
  4. delete [] data; // when you have finished with it delete it!
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: error C2447: missing function header (old-style formal list?), what does this mea

 
0
  #7
Dec 18th, 2004
Yes, actually this is an assignment, :o but I don't want anybody to do it for me, I just need some hints. As you can probably tell I am very new at this, and I would not be posting here because I know that it is somewhat annoying to have everybody wanting someone else to do their homework for them. However I have a matter of days to get this done and I spend all my time on the computer working on it. The requirements for the program are: to write a program using a linked list that prompts the user for the days and temperatures and then calculates the average temperature. I have modified the get_temp function from the last post, and now the output displays the last day and the first temperature.

Here is the modified section of code:

  1. int get_temp(int days, float &temp)
  2. {
  3. int keep_data = 1;
  4.  
  5. if(day_counter == days)
  6. {
  7. keep_data = 0;
  8. }
  9. else
  10. {
  11. days = day_counter + 1; // note that day_counter is a global variable
  12. cout << days;
  13. cout << "enter the temperature for day " << day_counter + 1 << endl;
  14. cin >> temp;
  15. day_counter++;
  16. }
  17. return(keep_data);
  18. }
Last edited by alc6379; Dec 20th, 2004 at 1:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #8
Dec 19th, 2004
I do not know if anyone is even paying attention to this thread anymore but I found something wrong with the program nevertheless. In my show_temps function I forgot to add current_ptr = current_ptr->next; . That explains ALOT. Anyway, the program now displays all the temperatures the user adds but it only displays the last day. For example: Day: Temperature:
3 10
3 20
3 32.2
any ideas on how to fix this would be appreciated. If there is anyone out there reading this and they do not mind helping me, here is newest version of source code:

  1. #include<iostream.h>
  2.  
  3. struct temperature_node
  4. {
  5. int day;
  6. float temperature;
  7. temperature_node *next;
  8. };
  9.  
  10. int day_counter = 0;
  11.  
  12. temperature_node *head_ptr;
  13. temperature_node *current_ptr;
  14.  
  15. int get_temp(int days, float &temp);
  16. void show_temps();
  17. void remove_temps();
  18. void add_temp(int days, float temp);
  19. void move_c_to_end();
  20.  
  21. int main()
  22. {
  23. int days;
  24. float temp;
  25.  
  26. cout << "enter the days for which you have data ";
  27. cin >> days;
  28.  
  29. if(get_temp(days, temp))
  30. {
  31. head_ptr = new temperature_node;
  32. head_ptr->day = day_counter;
  33. head_ptr->temperature = temp;
  34. head_ptr->next = NULL;
  35. while(get_temp(days, temp))
  36. {
  37. add_temp(days, temp);
  38. }
  39. show_temps();
  40. remove_temps();
  41. }
  42. return 0;
  43. }
  44.  
  45. int get_temp(int days, float &temp)
  46. {
  47. int keep_data = 1;
  48.  
  49. if(day_counter == days)
  50. {
  51. keep_data = 0;
  52. }
  53. else
  54. {
  55. days = day_counter + 1;
  56. cout << days;
  57. cout << "enter the temperature for day " << day_counter + 1 << endl;
  58. cin >> temp;
  59. day_counter++;
  60. }
  61. return(keep_data);
  62. }
  63.  
  64. void add_temp(int days, float temp)
  65. {
  66. temperature_node *new_rec_ptr;
  67. new_rec_ptr = new temperature_node;
  68.  
  69. new_rec_ptr->day = days;
  70. new_rec_ptr->temperature = temp;
  71. new_rec_ptr->next = NULL;
  72.  
  73. move_c_to_end();
  74. current_ptr->next = new_rec_ptr;
  75. }
  76.  
  77. void move_c_to_end()
  78. {
  79. current_ptr = head_ptr;
  80.  
  81. while(current_ptr->next != NULL)
  82. {
  83. current_ptr = current_ptr->next;
  84. }
  85. }
  86.  
  87. void show_temps()
  88. {
  89. current_ptr = head_ptr;
  90.  
  91. do
  92. {
  93. cout << current_ptr->day << " ";
  94. cout << current_ptr->temperature << endl;
  95. current_ptr = current_ptr->next;
  96. } while(current_ptr != NULL);
  97. }
  98.  
  99. void remove_temps()
  100. {
  101. temperature_node *temporary_ptr;
  102.  
  103. current_ptr = head_ptr;
  104.  
  105. do
  106. {
  107. temporary_ptr = current_ptr->next;
  108. delete current_ptr;
  109. current_ptr = temporary_ptr;
  110. }while(temporary_ptr != NULL);
  111. }

Thanx
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #9
Dec 20th, 2004
I forgot to add current_ptr = current_ptr->next;
Common linked list error. By discovering it at least you have learned something! im sure we were paying attention, but from experience i find that giving hints rather than complete solutions helps you to learn faster! - and that ive only had time to post VERY late at night and im too tired to wade through code lol
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: error C2447: missing function header (old-style formal list?), what does this mean?!

 
0
  #10
Dec 20th, 2004
Yeah the whole current pointer bit made me feel pretty stupid. :o Anyway the program is still not displaying the proper day. I really appreciate the help you have been giving me, and I just wanna say thanx. If you do not really want to go through my code that is cool because I think I'll figure it out eventually, but if you do happen to go through it and find something you can give me a hint on that's even cooler I now can only get the last day to display and not any of the others.

thanx again
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC