All Questions
44 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 ...
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 ...
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
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(...
-1
votes
3
answers
142
views
Write a program that converts a string to an integer without using standard C library functions
#include <assert.h>
#include <stddef.h>
#include <string.h>
int StringToInteger(const char *str) {
int num = 0;
int sign = 1;
assert(str != NULL); //assert that str ...
1
vote
3
answers
353
views
Count and return the number of letters of each word in C
I'm learning C and I've created some small "challenges" for myself to solve. I have to create a program that reads an input string which consists of words separated by underscore and returns ...
0
votes
1
answer
64
views
strstr not working with needles shorter than 3 char
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* findSequence(char s[], char ch, int n){
int i;
char*ptr;
char needle[n];
char*npdr=&needle;
...
0
votes
1
answer
151
views
How do I append character gotten from loop to a string and return the value of the string as my output
I wanted to return characters as a single string after making each character uppercase in C language (Not using printf or putchar). The aim is to return the value of the string after adding each ...
0
votes
1
answer
93
views
Replacing a sequence of ascending characters by ascii code with a specific pattern
I am doing some kind of challenge in C in the internet and got the following mission:
Given a string, that consists of some ascending characters one after the other (by ASCII value), return the same ...
1
vote
1
answer
68
views
Doubling all occurrences of a specific character in a string
I want to write a C program, that returns a new string allocated on the heap. This string is obtained by doubling all occurrences of “c” in a string (“abcdc” becomes “abccdcc” after doubling “c”).
...
-1
votes
2
answers
107
views
How do you reverse the word order in a sentence?
The task was to reverse the order of words in the sentence
I was able to reverse the order of the words, but the problem is that the order of the letters in the word also changes
For example: cats and ...
1
vote
1
answer
139
views
How to change one string to another with different sizes
I have a task to do. I have to work with strings. I will show you the input and output, because I think that will be clear what the task is.
Input: "aaa bbuvvvvo"
Output: "a$3 b$2uv$4o&...
0
votes
3
answers
205
views
Buffer overflow? strncat() in C
I'm very new to C, and I want to make a simple program that gets an index of a string from the value, and once it has the index, it removes it from a string. It's causing a buffer overflow error? ...
-2
votes
2
answers
517
views
Is this a good way to remove spaces from a string in C? note, I am only using the <stdio.h> header file. Also I am new to computer science
int remove_whitespace(char* string, int size) /* input parameters: the character array, size of that array */
{
int i = 0, j = 0, num = 0; /* i - counter variable | j - counter variable | ...