473,394 Members | 1,722 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,394 software developers and data experts.

Issue with pointer assignments

22
here is my code that I am working with:

Expand|Select|Wrap|Line Numbers
  1. /*
  2.      File Name:  lab5.c
  3.      Author:  Nick Cantey
  4.      Description:  This program gathers the properties of numbers entered.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. #define DIVIDE 10
  10.  
  11. void integerDivideBy10 (int, int*, int*);
  12. int sumOfDigits (int);
  13.  
  14. int main () 
  15.  
  16. {
  17.  
  18.  
  19. int number, quotient, remainder, sum;
  20.  
  21.  
  22. prinft("Please enter an integer: ");
  23. scanf("%d", &number);
  24.  
  25. while (number != 0); 
  26.     {
  27.      void integerDivideBy10(number, int* quotient, int* remainder);
  28.      sum = sumOfDigits(number);  
  29.      printf("%d / 10 is %d with a remainder of %d\n", number, quotient,
  30.             remainder);
  31.      printf("Please enter an integer: ");
  32.      scanf("%d", &number);
  33.     }
  34.  
  35. }
  36.  
  37. /*
  38.      Function Name:  integerDivideBy10
  39.      Parameters:  number, int* quotient, int* remainder
  40.      Description:  function divides by 10 and returns the quotient and remainder
  41. */ 
  42.  
  43. void integerDivideBy10 (int number, int* quotient, int* remainder)
  44.  
  45. {
  46. while ( number !=0 ) 
  47. int* quotient = number / 10;
  48. int* remainder = number % 10;
  49. }
  50.  
  51.  
  52. }
  53.  
  54. /*
  55.      Function Name:  sumOfDigits
  56.      Parameters: number
  57.      Description:  funtion returns the sum of all "number"'s digits
  58. */
  59.  
  60. int sumOfDigits (int number)
  61.  
  62. {
  63.  
  64. int sum = 0, remainder;
  65. while (number != 0)
  66. {
  67.     remainder = number % DIVIDE;
  68.     number = number / DIVIDE;
  69.     sum += remainder;
  70. }
  71.  
  72. return (sum);
  73.  
  74. }
  75.  
My problem occurs in the "integerDivideBy10" function where it gives me the following errors when I try to compile:

lab5.c:27: parse error before `int'
lab5.c: In function `integerDivideBy10':
lab5.c:47: warning: initialization makes pointer from integer without a cast
lab5.c:48: warning: initialization makes pointer from integer without a cast

Some one please look this over, and if someone could also explain why I am getting the initialization errors.

The purpose of this program is to ask the user for an "integer" and then take that integer and divide by 10. Then also take the "integer" and and gather the sum of the digits within that number. i.e. 123 = 1+2+3 = 6 .
Apr 1 '07 #1
1 1207
canteyn
22
Nevermind, problem solved.
Apr 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Roger Davis | last post by:
Hi all, My slave has been working fine up until now. Here is the error message. 030730 11:32:28 Slave: connected to master 'repl@xxxx.xxx.org:3306', replication started in log...
11
by: Rajesh | last post by:
Dear All, Please let me know the advantage of function pointer? Is it fast calling function using function pointer? Is it possible to use function pointer to optimise code? Thanks and regards...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
48
by: yezi | last post by:
Hi, all: I want to record some memory pointer returned from malloc, is possible the code like below? int memo_index; int i,j; char *tmp; for (i=0;i<10;i++){
27
by: Erik de Castro Lopo | last post by:
Hi all, The GNU C compiler allows a void pointer to be incremented and the behaviour is equivalent to incrementing a char pointer. Is this legal C99 or is this a GNU C extention? Thanks in...
30
by: Joe Smith | last post by:
A recent post of mine showed a sufficiently large gaffe on pointers as to need to return to K&R 5.1-6 appendix A8.6.1 . So we have type specifiers: int long .. One dreams himself variable...
3
by: Steven Blair | last post by:
I have encountered this problem a few times and would like to see how other people deal with it. A library has a Constructor that takes in n params and does some basic validation and populates...
41
by: Summercool | last post by:
Can we confirm the following? also someone said, Java also has "reference" like in C++, which is an "implicit pointer": Pointer and Reference --------------------- I am starting to see what...
11
by: Logan Lee | last post by:
It is at http://211.30.198.135/pointer_operations.html. I want to get this reviewed to make sure that they are correct. I'm not sure whether copy/paste will show up correctly but the content is: ...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.