Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 295 characters in body
Source Link
sk.76
  • 312
  • 3
  • 15

The following is my code for pset2 initials 2017 and I got a segmentation error. Can someone plse help me debug this.

int n = 1;
printf("Hello what's your name?\n");
string name = get_string();
printf("%c",toupper(name[0]));
while(1 <= n <= strlen(name))
{
    if(name[n] == ' ')
    {
        printf("%c",toupper(name[n+1]));
    }
n++;
}
printf("\n");

Now here's the output :

Hello what's your name?
ansh parashar                                                                    
APSegmentation fault

Please help me find the way to fix this segmentation fault.

The following is my code for pset2 initials 2017 and I got a segmentation error. Can someone plse help me debug this.

int n = 1;
printf("Hello what's your name?\n");
string name = get_string();
printf("%c",toupper(name[0]));
while(1 <= n <= strlen(name))
{
    if(name[n] == ' ')
    {
        printf("%c",toupper(name[n+1]));
    }
n++;
}
printf("\n");

Now here's the output :

Hello what's your name?
ansh parashar                                                                    
APSegmentation fault

Please help me find the way to fix this segmentation fault.

The following is my code for pset2 initials 2017 and I got a segmentation error. Can someone plse help me debug this.

Now here's the output :

Hello what's your name?
ansh parashar                                                                    
APSegmentation fault

Please help me find the way to fix this segmentation fault.

Source Link
sk.76
  • 312
  • 3
  • 15

Segmentation fault in initials.c pset2 cs50 2017

The following is my code for pset2 initials 2017 and I got a segmentation error. Can someone plse help me debug this.

int n = 1;
printf("Hello what's your name?\n");
string name = get_string();
printf("%c",toupper(name[0]));
while(1 <= n <= strlen(name))
{
    if(name[n] == ' ')
    {
        printf("%c",toupper(name[n+1]));
    }
n++;
}
printf("\n");

Now here's the output :

Hello what's your name?
ansh parashar                                                                    
APSegmentation fault

Please help me find the way to fix this segmentation fault.