Hello folks,
I need to write a function that takes a C-style string as an input and returns its length. It must be done in a modular way by creating three separate files, stringLen.h, stringLen.C and useStringLen.C. useStringLen.C takes a command line argument and display its length by calling the function stringLen.
This is my header file.
Code:
//// stringLen.h ////
size_t strlen(const char * str);
My loop function to count the length of the string.
Code:
//// stringLen.C ////
#include "stringLen.h"
int stringLen(int a, int n)
{
int i, ans=1
for (i=1; i<=n; i++) { ans *=a; }
return ans;
}
And my main function.
Code:
//// useStringLen.C ////
#include <iostream>
#include "stringLen.h"
int main(int argc, char *argv[])
{
return0;
}
I know there are errors but I am confused how to integrate the three. Can anyone help me out? I would appreciate it.
Thank you.