Thread: need help with pointers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    16

    need help with pointers

    the first function works (int length (char a[]), but the output to the second function is -28865. I need to use pointers and pointer arithmatic.

    Code:
    #include <stdio.h>
    #include <string.h>
    
    int length (char a[]);
    int point_size (int *a);
    
    int main()
    {
    char word[]="Trying this out";
    int size;
    int pointer_eh;
    
    size = length (word);
    
    printf("The length is %d\n", size);
    
    printf("The length is %d", pointer_eh);
    
    
    return 0;
    }
    
    
    int length (char a[])
    {
    	int i;
    	int size=0;
    
            clrscr();
    
            for (i = 0; i != strlen(a); i++)
    	{
    		size++;
    	}
    	return(size);
    }
    
    int point_size (int *a)
    {
    
    	int i, pointer_eh;
    
    	while (*a[i] != '\0')
    	{
    		*(a+1);
    	 	i++;
    	}
    	return (pointer_eh);
    }
    Last edited by digy; 08-14-2003 at 08:43 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM