Hello.
I have um simple program that just count how many args are introduced by user.
Example: insert 20 30 should say 3 args. The problem is i can count the args correctly but one of my variavles changes and i don't want.
Code:
#include<stdio.h>
#include<stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <string.h>
int num_args(char *op)
{
int number=0;
char *temp;
temp = strtok (op," ");
while (temp != NULL)
{
number++;
/* printf ("%s\n",pch);*/
temp = strtok (NULL, " ");
}
return number;
}
int main ()
{
char *r;
int a;
r=readline("LETRAS: ");
a=num_args(r);
printf("Number of ARGS: %d and comand:%s\n",a,r);
}
as you can see i want to keep r as it was after user insert the comand, but when i passed to function changes.
Help me please....
Tks
HIT