All Questions
Tagged with c-strings function-definition
259 questions
4
votes
3
answers
138
views
remove a character by using conditional statement
recently just practiced the problem 67 in Leetcode This problem is like you would be given two binary string, and you have to calculate the sum of these two binary string and return the result.For ...
3
votes
4
answers
166
views
Change pointer adress inside function in C
I'm trying to make a program that deletes extra white spaces from a string. It should keep one space but delete any extra.
I wrote this code, which works up until the point I have to change the passed ...
1
vote
2
answers
62
views
Line extraction in a char
Hi i'm trying to write a recursive function to extract each line of a string. I don't know why it doesn't work i spent 2 hours trying to find the issue.
#include <string.h>
#include <stdlib.h&...
1
vote
2
answers
191
views
Returning the remaining string in strtok function?
I am writing my own strtok function. How do I make it so that it will return the remaining string as an output parameter?
Here is what I made so far.
char *mystringtokenize(char **string, char ...
1
vote
2
answers
256
views
Fibonacci for letters
I was programming a code for a case provided by my university. It was about making a Fibonacci function, but for letters. For example, if f(0) -> a, f(1) -> b, then f(2) -> ba, and so on. I ...
0
votes
2
answers
181
views
Why do I get a segmentation fault? The code works fine in CLion and VSC
I am currently using exercism, to improve my programming skills. The code works fine in my IDE, but causes an error message on the website. What did I do wrong and how would you improve my code? Thx ...
1
vote
3
answers
79
views
I'm trying to call a function inside of a token loop in C. I keep segfaulting?
#include <stdio.h>
#include <string.h>
void pigLatinConsonant(char input[]) {
char end[] = "ay";
int length = strlen(input);
int first_vowel = -1;
for (int i ...
3
votes
3
answers
110
views
Why is the new string not being printed after adding char characters?
I'm stating to write some leetspeak code in C, however, I keep getting error like:
error: incompatible integer to pointer conversion returning 'char' from a function with result type 'string' (aka '...
0
votes
1
answer
117
views
Count Frequency of a Substring in a String
Given a string T and a pattern P which is also a string. Find the number of occurrences of P in T.
Input
Line 1: contains string P (length is less than or equals to 10^5)
Line 2: contains the string T ...
-3
votes
3
answers
122
views
I have a program that capitalizes all words of a string. The program is working but I want to understand what the code is doing
#include <stdio.h>
char *cap_string(char *str);
int main(void) {
char str[] = "Expect the best. Prepare for the worst. Capitalize on what comes.\nhello world! hello-world 0123456hello ...
0
votes
1
answer
54
views
Operation on string inside function
Why does putting reverse() inside main() print 12345 while putting reverse() as the last statement of itoa() definition produces 54321?
#include <stdio.h>
#include <string.h>
void itoa(...
0
votes
1
answer
125
views
Searching an element in linked list
I want to search in a linked list that stores names, I created the function but the printf statements that output if the element was found or not don't print anything. The code seems correct, I tried ...
1
vote
3
answers
169
views
Dynamic string array in C
I was trying to code something to practice the C langage.
What I wanted to do (again only to practice, not for any use) was to create some kind of inventory system on which you could add an item in or ...
2
votes
2
answers
194
views
string copy() function return misunderstood? (C)
(EDIT)
Probable misunderstanding in updating and returning a string from a function in C.
I'm a student and have just started trying out dynamic memory allocation techniques. Recently, I was told to ...
0
votes
2
answers
73
views
I need to remove all whitespaces from the input string and copy the new string to the other string in the deblank function. I am getting zsh bus error
When I try to run this code it successfully asks me for a string and assigns it to the inpstr. When I call the deblank function i get "zsh bus error" Any help would be highly appreciated.
...