Questions tagged [string]

The tag has no usage guidance.

16 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
1answer
20 views

Segmentation fault with overwriting chars

I tried overwriting cipupperalphabet[j] from a A to a B, but it has caused a segmentation fault. string upperalphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string cipupperalphabet = upperalphabet; int j = ...
0
votes
1answer
11 views

Find hex values inside a string in C?

I have a long string "given_string", and I'm trying to find hex values within that string. Here's a simplified example: /* Find a sub-string in a given string: */ char * given_string = &...
0
votes
1answer
15 views

When I multiply my array by 2 it doesn't give expected value

Also, please when I try to add "firstnumsum", it doesn't give expected value and I don't know what to do. #include <cs50.h> #include <stdio.h> #include <string.h> #include &...
0
votes
1answer
47 views

incompatible pointer types passing 'string' (aka 'char *') to parameter of type 'string *' (aka 'char **')

Im writing a funtion that takes string as a argument and gives back a integer. This function counts lenght of a string entered at the command line argument. I get an error :" incompatible pointer ...
0
votes
1answer
45 views

i don't know what's wrong with my code. Trying to convert from string to long

INPUT int main(void) { long long cardnumber, calc; string credit[0]; string nonnumeric; //long long calc = card number; int countcardcharacters = 0; long long c; //user input do { credit[0]= ...
0
votes
0answers
25 views

Readability(checking punctuation to determine number of sentences)

here is my code; trying to detect punctuation (!, ., ?) to determine the amount of sentences, however keep getting error messages. would appreciate any help. my code and error messages are below; #...
0
votes
1answer
17 views

How to swap strings?

The main problem comes when we swap strings of unknown lengths. Lets say we have two strings assigned to two variables say a, b. Now if I use a temporary string say c, and use strcpy(c,a), then use ...
0
votes
1answer
18 views

sans trailing line ending?

I can't seem to find an explanation for the phrase "sans trailing line ending"? From what I can gather, line ending refers to CR (carriage return) and NL (newline) but I still can't grasp the meaning ...
0
votes
1answer
275 views

String being replaced by garbage before being printed

I have this code: #include <cs50.h> #include <stdio.h> #include <string.h> string increment_str(); int main() { string s = increment_str("xyz"); printf("String: %s\n", s); }...
0
votes
1answer
35 views

warning: deprecated conversion from string constant to ‘string {aka char*}’ [-Wwrite-strings]

I'm a complete beginner who just commenced on the CS50 course through EDX. While tryin out the walkthrough lessons in the CS50 IDE (clou9), I'm getting the following warning "TEST.C: In function ‘...
0
votes
3answers
307 views

Sentinel value in arrays

Why don't we use the backslash zero in integer arrays to save memory or prevent overflow like character arrays or strings?
0
votes
1answer
165 views

Parse Function: Extra characters in string after using memcpy

My parse function works for the root directory, but for subsequent requests for, say, cat.jpg, the memcpy function seems to copy an extra \220 into both requesttarget and HTTPversion (so, for instance,...
0
votes
0answers
117 views

Why can't I create an array of strings?

I have this habit of first trying out all the exercises of the book then going on to psets. I am on chapter 7, arrays. the question was to make a program of some sort of voting counter and instead of ...
0
votes
0answers
186 views

Problem using a function to manipulate strings in pset6 server

This given code in server.c gets the slice of string up to an appearance of \n. const char* haystack = request; char* needle = strstr(haystack, "\r\n"); if (needle == NULL) { ...
0
votes
1answer
104 views

String validity check when string is command line argument?

We check the string validity when we use the get_string() function. Example: if (p != NULL) Are we also supposed to check string validity when the string is entered as a command line argument?
-1
votes
1answer
171 views

array of strings

input : T - test cases and then next T lines. Each line contains a word(string). I want to take them as an input and store them in a 2D array, like char string[T][ ]; example input : 3 ...