Questions tagged [strstr]

A function that searches a string in another string.

A function that searches a string in another string.

Examples

php
$email  = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com

(Example taken from php.net)

Resources

363 questions
-2
votes
2 answers

How to count value from strstr function php?

I try to get value after symbol '@' and count it. But this code doesn't give the correct result. How to fix it? $t="Hi, I invite @nina and @nana to come to my party tomorow"; $arr=explode(' ', $t); foreach($arr as $user ) { $result=strstr($user,…
lolagi
  • 61
  • 1
  • 8
-2
votes
1 answer

strstr() always returns null

I'm working on program where I would like to find a match in a string. I am using the strstr() function to get the job done, but it has a weird behaviour. I am using fgets() to read the string and then using strstr() to find a match, but it always…
Abdir
  • 87
  • 1
  • 1
  • 6
-2
votes
1 answer

Search my name in statement ! in c program using string functions

I need to know whats wrong with this code. #include #include int main() { char a[50], b[100], c[5000]; char *ret; //enter first name gets(a); //enter secend name gets(b); //enter statement …
-2
votes
1 answer

Find string in another string

So I have a .txt file with the following format: abc@example.com:number cde@example.com:number efg@example.ru:number And another file with: abc@example.com efg@example.ru And I want to using the email from second file to find the…
GregMerk
  • 19
  • 3
-2
votes
2 answers

found a string with strstr() inside a txt

I want to make a code in c for searching how many times a string is found inside a txt file using strstr() function. I have made a test code with strastr() but I have a problem. e.g I have sentence like " this is a text" and when I search for "is" I…
-2
votes
1 answer

C Programming. Convert string www.as.com to 3www2as3com0

please can you give me some ideas to convert a string such as: char string[20]="www.msn.es" to another string : 3www3msn2es0 . I just want ideas please, should I use strstr or you just can do it with char pointer and bucles. Thanks so much, it's my…
-2
votes
2 answers

How to read part of a txt file

I have the following basket.txt file Center defence=45 training=95 Shooter points=34 Rebounds=7 Shooter points=8 Rebounds=5 Forward points=8 Rebounds=5 I want to get and display only the Shooter values. To return something like…
dali1985
  • 3,263
  • 13
  • 49
  • 68
-2
votes
2 answers

counting the number of characters in a line of C

Possible Duplicate: memcpy and malloc to print out a string I need to find the number of characters in a line of a text file after a '=' sign until the end of the line or the '#' symbol. I then need to work backwards till I reach the first non…
user1984300
  • 101
  • 3
  • 15
-2
votes
1 answer

strstr() function in PHP is not working whatsoever

I'm running PHP 5.3.8 on my local, 5.2.17 on my remote. strstr() works fine on my local, but when loaded in remote it returns nothing. Even error reporting doesn't say anything. A simple use of it: echo strstr('1234567890', '3', true); should…
Jiminy Cricket
  • 908
  • 1
  • 9
  • 24
-3
votes
1 answer

Segmentation Fault while implementing my own strstr() function

I trying to implement strstr(str, substr) function. i tried implementing in two ways, my main goes like this *#include char * my_strstr(char * str, char * substr); int main() { char str[10], substr[10]; char *ptr; …
-3
votes
1 answer

strstr() don't work in PHP

I have this code in PHP with that uses the function, strstr(): $conversation = strstr($bash, '_'); $pseudo = strrchr($bash, '_'); //On ajoute les balises html au pseudo et a la conversation $cherche = array($pseudo, $conversation); $remplace =…
-4
votes
2 answers

Faster version of strstr for fix string

I have a short string s (max 8 characters) which I want to search in many strings. Actually I want to search the first occurrence in each string of a stream. Finding the first index of s has to be as fast as possible for my use-case, because a…
Kevin Meier
  • 2,339
  • 3
  • 25
  • 52
-4
votes
3 answers

After using strstr() the substring also transmitted via uart

I was trying UART using STM32F407V6T6 and CubeMx. As I have posted some problems with strstr() function. Here is some new problems. Here is the code: char rxBuff[10]; int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); …
sourav maity
  • 23
  • 1
  • 7
-4
votes
4 answers

c for loop break statement doesn't work

I've written a for loop that searches a string in another. I want it to rename it's position when it finds it. ( I am open for new suggestions for the search :) ) int search (char str1[56], char str2[5]){ int c1, c2, c3, c4; c1 = 0; for…
cskr
  • 77
  • 2
  • 9
1 2 3
24
25