So here's my code:
#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(int argc, string argv[])
{
(void)argc;
(void)argv;
//k production function starts here
int k = get_int("Enter a non negative k: ");
while (k < 1)
{
k = get_int("Enter a non negative k: ");
if (k >= 1)
{
break;
}
}
//return 0; above function works
//k function ends here
//cipher function starts here
string p = get_string("Enter message here: ");
int i = strlen(p);
while (true){
if (isalpha(p[i]))
{
break;
}
printf("Please enter an alphabetical string to encipher...");
p = get_string("Enter message here: ");
if (isalpha(p))
{
break;
}
}
return 0;
}
And I think I know why I'm getting the segmentation fault (I think it's because of my isalpha function's variable: if (isalpha(p[i])) but I don't know how to pass an integer as the number of characters in the char array.Can you guys give me some pointers? P.S. I know my code is far from done, I'm just trying to get this out of the way first.