S
Sparticus
It's been many years since i've programmed in c. I am trying to do
somethign so simple, but it seems impossible. There has to be an
easier way than what I am doing.
What I want to do is build a string with user variables placed within
it... for example :
name = "Ryan";
age = "28";
mystring = "Hello, my name is " + name + " and I am " + age + " years
old";
(I know that won't compile, but I'm trying to find a way to do
something like that)
So when this is run, the variable mystring would contain :
"Hello, my name is Ryan and I am 28 years old"
How do I do this?
This is how I am doing it so far and there has to be a better way :
strcpy(mystring,"Hello, my name is ");
strcat(mystring,name);
strcat(mystring,"and I am ");
strcat(mystring,age);
strcat(mystring,"years old);
Thanx a bunch for the help!!
Ryan Ritten
somethign so simple, but it seems impossible. There has to be an
easier way than what I am doing.
What I want to do is build a string with user variables placed within
it... for example :
name = "Ryan";
age = "28";
mystring = "Hello, my name is " + name + " and I am " + age + " years
old";
(I know that won't compile, but I'm trying to find a way to do
something like that)
So when this is run, the variable mystring would contain :
"Hello, my name is Ryan and I am 28 years old"
How do I do this?
This is how I am doing it so far and there has to be a better way :
strcpy(mystring,"Hello, my name is ");
strcat(mystring,name);
strcat(mystring,"and I am ");
strcat(mystring,age);
strcat(mystring,"years old);
Thanx a bunch for the help!!
Ryan Ritten