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
0
votes
2 answers

extracting string occurrence in c

I have a string that look something like this: long_str = "returns between paragraphs 20102/34.23\" - 9203 1232 \"test\" \"basic HTML\""; Note: Quotes are part of the string. int match(char *long_str){ char * str; if ((str =…
David78
  • 23
  • 1
  • 5
0
votes
3 answers

strstr will not return a true value

I am working on this example in a C programming book and the strstr command is supposed to trigger the printf command when the value is true. It is trying to find a string within tracks and return which track it was found in. I have palyed around…
Jpm61704
  • 60
  • 2
  • 8
0
votes
3 answers

Incorrect usage of a for loop in strstr() in C

I am trying to learn string handling in C. I wrote out a program, which stores some music tracks, and helps the user to check if the song he/she has in mind, exists in the tracks stored. This is done by asking the user to enter a string of…
Manish Giri
  • 3,562
  • 8
  • 45
  • 81
0
votes
1 answer

'C' get length of substring from large buffer using strstr() and subtracting two pointers

I have a circular buffer of of ASCII text that is 1000 bytes long. It is going to be constantly being updated and appended to. My problem is I am using strstr() to pinpoint where a section of data starts by looking for a "$GPRMC" and I am looking…
Wesley Carlsen
  • 137
  • 3
  • 19
0
votes
2 answers

strstr not working in C++ 4.7 on codeforces

On online compiler this program is giving perfect output on giving input "ABACABA", but on Codeforces tests it is just posting the last line. On debugging I found out that the pointer u is indicating to address 0 when strstr() is used. I am unable…
user3642625
  • 57
  • 1
  • 1
  • 8
0
votes
1 answer

Searching a word in a 2d array in c programming

I am trying to set up a program that when you type /s then a movie title (ex. /s Green Mile it searches for that movie title in the movies array but my strstr function is not working. Also /a adds movie /r shows all movies in database and /q quits…
0
votes
1 answer

Delete a list entry based on substring find

I want to write a function, that deletes an entry of a structure list if it finds a substring in the name of the author saved in the structure. The problem is, that strstr() does not seem to find any match. I dont want to know if I am deleting the…
user3501229
  • 13
  • 1
  • 3
0
votes
1 answer

How do you split strings in Ruby like Strstr in PHP

I want to know how you split a string in ruby. In PHP you can use the function Strstr to do this. I have tried the following code to achieve…
Astm
  • 1,519
  • 2
  • 22
  • 30
0
votes
1 answer

strstr char array inside struct array with user input

Can someone tell me why p is always NULL even if strstr correctly found (in search function)? I'm filling struct array from file. Sorry for re-post of this other question but none of them are helped. #include #include #include…
0
votes
1 answer

Distiguish between Shared Library (.so) and command

I am trying to tell if the argument they give me is a Shared Library or a command I order to load the library or the exec with that especific command. Right now what I am trying to do is: if(strstr(argv[1],".so")!=NULL){ //Load library…
narib
  • 19
  • 4
0
votes
1 answer

Using the C++ strstr function to remove the part of the substring your are searching for

I have an exercise question in class that has me stumped which is write a function named strCut that receives two C-style string parameters s and pattern. If the pattern string is contained in s, then the function modifies s such that the first…
user2027757
  • 13
  • 1
  • 6
0
votes
2 answers

Fastest way to retrieve part from JSON in my case

Now, I use strstr to get data from external JSON file. I'm not sure if it's the fastest way to do that what I want and I can't test because json_decode don't work in my code. $before = '"THIS":"'; $after = '","date"'; $data = strstr(substr($url,…
Kratalin Jan
  • 105
  • 10
0
votes
3 answers

weird behaviour of strstr in qt program

I'm a beginner, made a function which takes input from lineedit converts it into a array and then searches it to find a word. If the word is found it prints successs in a label, otherwise prints error.Problem is that it every time prints error no…
Amol Borkar
  • 2,321
  • 7
  • 32
  • 63
0
votes
1 answer

strstr in switch statements

I'm making a program that lets user enter a string then program searches various words in the string using strstr function, then calls different functions according to which word is found.I decided to use switch statements to check which words are…
Amol Borkar
  • 2,321
  • 7
  • 32
  • 63
0
votes
1 answer

C find replace isn't working

Here is the function that isn't working: char * insert_symtab(char *buf) { char *ret = (char *)malloc(strlen(buf) + 512); char *tmp = NULL; char *repl = NULL; char obuf[32]; //for converting int to hex Symtab_struct *cursym; lineQueue…
phyrrus9
  • 1,441
  • 11
  • 26