Yamaha32088 Yamaha32088 - 1 year ago 105
C Question


I keep getting this error trying to run the debugger:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00007fff8c2414f0 in strlen ()

Here is my code:

#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

int main(int argc, char *argv[])
char s2[25];
strcpy(s2, argv[1]);
int keyLen = strlen(s2);
printf("Please enter a string of text to be encrypted!\n");
string p = GetString();
for (int i = 0, n = strlen(p); i < n; i++)
if (isupper(p[i])){
int sum = (p[i] - 'A') + (s2[i % keyLen] - 'A');
char c = 'A' + sum%26;
printf("%c", c);
printf("%d\n", keyLen);


I can compile the code with no errors and it works like it should. I am running the debugger to step into the
loop and look at what the math is doing to better understand it.

Answer Source

I finally got it thanks to hmjd I was running it incorrectly I would start the program

gdb vignere HHHHH

Which is incorrect I ran it

gdb vignere

and it worked perfect!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download