Hi,
anyone knows how to sum two string variables, I've tried with strcat but this function accept as the second parameter only a constant string. I want to do something like this:
char var1[10], var2[10], var3[20];
var1 = strcpy(var1,"hewhwho");
var2 = strcpy(var2,"fhhgoehg");
var3 =...
I tried this as input...
#include <stdio.h>
int main(int argc, char *argv[])
{
char *input = (char *)malloc(1000*sizeof(char));
gets(input);
printf("%s",input);
}
...looks for me simpler and works fine, but dunno why compiler tells me that gets is a dangerous function and should not be...
@ArkM
Yes, I was thinking the same, someone from school say me to use read and write, but I noticed that these function are really out of scope.
On the other hand using these I had to understand well pointers.
I fix the room issue for ShellTxt, also if it does not creat problem. Thanks SamBones.
@Trojan
Yes, probably I overwrite the last char but is what I want, I think that the read function add also a \n to the buffer and don't close the string with \0.
So "cmd[nByte-1]='\0';" overwright the \n...
I wrote this, works nearly as expected but on the last element extracted from input string it attach various unexpected character, please any suggestion??
In particular look at divCmd function.
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define BUFLEN 1024
#define STDIN 0...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.