I am trying to implement the UNIX type shell. I have not implemented the shell creating a child process to run each command part, but this is just a code to break the string entered at the command prompt by the user into the appropriate arguments by using a space as a delimiter, which will then be passed to the file corresponding to the command (say ls -l) as command line arguments.
It runs alright on my Windows 7 OS, but when I run it on Ubuntu with my input string as "ABC XYZ WGH", I get an error, saying "Undefined symbol 'printf' version ABC." Please help me understand, where I am going wrong?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int arguments(char str[],char *** args)
{
    char *s;
    int num;
    int i;
    s=(char*)calloc(strlen(str)+1,sizeof(char));
    strcpy(s,str);
    if(strtok(s," ")==NULL)
    num=0;
    else
    {
        num=1;
        while(strtok(NULL," ")!=NULL)
        num++;
    }
    strcpy(s,str);
    **args=strtok(s," ");
    if(num)
    {
       for(i=1;i<num;i++)
       *((*args)+i)=strtok(NULL," ");
    }
    return num;
}
int main()
{
    char buffer[256];
    char **arg;
    int args;
    int i;
    while(true)
    {
           gets(buffer);
           if(!strcmp(buffer,"STOP"))
           break;
           args=arguments(buffer,&arg);
           printf("%d\n",args);
           for(i=0;i<args;i++)
           printf("%s\n",arg[i]);
    }
    return 0;
}
 
    