I'm trying to make a program which concatenates two strings. The max length of the strings should be 50 characters and I'm making a string with that size. I'm getting the strings using argv
. How can I detect if the strings are over 50 characters? Can I do it without playing around with memory since I haven't learned this yet. The function for concatenation is stored in a mystrings.h file Here's my current code:
#include <stdio.h>
#include <string.h>
#include "mystrings.h"
int main(int argc, char *argv[]) {
if (argc == 3) {
char str1[50];
char str2[50];
strcpy(str1, argv[1]);
strcpy(str2, argv[2]);
strConcat(str1, str2);
printf("Concatenated string: %s\n", str1);
} else {
printf("Invalid number of arguments passed. Format required:\n <STRING1> <STRING2>\n");
}
}