Thread: Trying to get ls -l say into a function.

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    20

    Trying to get ls -l say into a function.

    Hey.

    Im getting a warning message: passing arg 2 of `strstr' makes pointer from integer without a cast
    Im trying to bring in a string "ls -la" for example and to take it to my function....yet it fails to do so using this logic.

    Confused about this...Here is the snippet of code:
    Code:
    y = array;
         array2=NULL;
          
         while((r=strstr(y,' '))!=NULL)
    	
    	{
    	r[0]='\0';
    	array2=realloc(array2, sizeof(char**)*(c+1));
    	array2[c]=y;
    	y=r+1;
    	c++;
    	}
    
    	printf("%s\n", array);
    Cheers...

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    strstr takes a string, you're passing a character. Perhaps you want strchr instead?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM