Skip to main content

All Questions

Tagged with
1 vote
1 answer
107 views

Word Count in C

I have a word count program in C that excludes special characters and number digits: int main(){ char str[100]; int i, j = 0; int len; char choice; do { printf("...
Roshina De Jesus's user avatar
1 vote
1 answer
77 views

Longest common substring with restrictions

I have a function that finds and prints the longest common chain between two DNA chains. However I want to add some checks so my program can ignore characters that are not bases ('A', 'T', 'C', 'G') ...
ms complaints's user avatar
2 votes
1 answer
83 views

wcstok causes segmentation fault

I'm writing program that splits cyrillic text from stdin and prints it line by line. After reading text using fgetws i am getting Segmentation fault. Debugging with gdb returns this: Program received ...
unndere's user avatar
  • 33
1 vote
3 answers
76 views

Separating a long string into individual words in C

What I'm trying to do is, given a string (say "This is a string") write a code that could take it and put each word in a separate element of an array ("This", "is", "...
Blabla's user avatar
  • 231
1 vote
4 answers
115 views

strtok function c element considered problem

When I try to split a string with a delimiter, the strtok function doesn't consider empty strings and I would like to know how to fix it. For example, in my case, I have to split strings like "a-...
Leonardo's user avatar
0 votes
2 answers
114 views

reading input from .txt file in C

john smith 21 VETERAN 1 I have a .txt file writing this . I want to read this .txt file and take john smith as a variable . but I can't read with whitespaces. edit: I want to take john smith and ...
Player1 ready's user avatar
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 ...
fknoob's user avatar
  • 19
1 vote
1 answer
54 views

Why does the following code not work as intended

I have a string and I want to split it into words. The code works when the string passed ends with a space, but not otherwise CODE: void form_rule2(char * str) { int num_words=0; char word[20];...
Kuroro's user avatar
  • 21
5 votes
1 answer
131 views

What does ranges::starts_with do with C-style string argument(s)?

The following code prints 1010 #include <iostream> #include <range/v3/algorithm/starts_with.hpp> int main () { using namespace std::literals; std::cout << ranges::...
Enlico's user avatar
  • 28.9k
0 votes
3 answers
93 views

C Program returns unexpected output

This code is supposed to determine if a word is present in a sentence or not. I tried with the input sen:"my name is", search:"name", but it displays not found. Please help me. ...
Dhruv's user avatar
  • 3
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; ...
Tarkov Account's user avatar
0 votes
2 answers
146 views

input three strings into function, function needs to return the longest substring that is in all three strings

I have written the code already, and its pretty much finished, but while testing it, it would sometimes faulter(very rarely), and I cant quite figure out why.(Input three strings into function, ...
HelpMe's user avatar
  • 11
-1 votes
3 answers
43 views

How do I create an array based off an existing array where each element of the new array copies the original array until the first tab character in C

I have an array of strings read from a file. I'd like to take each string in the existing array and copy it to a new array unit the first instance of a tab character, and then move to the next element ...
Pepe S's user avatar
  • 65
0 votes
1 answer
210 views

I can not understanding this portion of code for this token identification program

I have got this code reference from a website and practicing with this. When I am trying to working with malloc() function then how we getting the value from right-left+2 // Extraction string char* ...
Rokibol Hasan's user avatar
0 votes
2 answers
883 views

C++ : Member reference base type 'char *' is not a structure or union

void find_substring(char * str_for_search_in, char * substring) { bool flag = false; for (int i = 0; i < strlen(str_for_search_in) - strlen(substring); i++) { if (...
Дамир Давлетшин's user avatar

15 30 50 per page
1
2 3 4 5