How do you strcat a string with "n" number of other strings of "x" length so that the final string only has "z" length? As an example:
Let's say I have 5 strings processed. They are these lengths:
p_str[0] 80
p_str[1] 65
p_str[2] 100
p_str[3] 10
p_str[4] 18
Now I want to load another string called final_string[190] with as much of the 5 strings processed as possible. So, with this example I will be able to get all of p_str[0] and p_str[1] and 45 of p_str[2] in there, not couting the '\0' and the newline from fgets. I have thought doing something like getting the strlen of each string before it is concatenated and using strncat with the amount of space I have left, subtracting when the amount left is less than the length of the current string. I think it's possible, but there must be a MUCH better way. Any help?
Thanks.
-Tyler
Let's say I have 5 strings processed. They are these lengths:
p_str[0] 80
p_str[1] 65
p_str[2] 100
p_str[3] 10
p_str[4] 18
Now I want to load another string called final_string[190] with as much of the 5 strings processed as possible. So, with this example I will be able to get all of p_str[0] and p_str[1] and 45 of p_str[2] in there, not couting the '\0' and the newline from fgets. I have thought doing something like getting the strlen of each string before it is concatenated and using strncat with the amount of space I have left, subtracting when the amount left is less than the length of the current string. I think it's possible, but there must be a MUCH better way. Any help?
Thanks.
-Tyler