Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 3018
0 votes
2 answers
173 views

pset 2 segmentation fault?

[email protected] This program encrypts a text in Caesar cypher. */ #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> char cypher(char c, int k); … ; for(int i = 0, n = strlen(s1); i < n; ++i){ s1[i]=cypher(s1[i] , k); } printf("Text: %s\n", s1); printf("Distancia wrap: %c\n", 'A'+25); return 0; } char cypher(char c, …
Carlos Esteban Lopez Jaramillo's user avatar
0 votes
Accepted

pset 2 segmentation fault?

Ok the issue in my code is that i'm trying to modify s1 in the same line of the cypher of s1 call, that gives a segmentation fault, to correct that i need other variable, but as i need a string of the … s1[i], k); } This for cyphers s1 character by character and return it to s2 in the correct index, or in the coresponding place in s2, then you can print s2 as the cyphered data as a string: printf("Cypher
Carlos Esteban Lopez Jaramillo's user avatar