Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:19:12+00:00 2026-06-14T12:19:12+00:00

For example I have: char buff[1000]; I want to search if the string hassasin

  • 0

For example I have:

char buff[1000];

I want to search if the string “hassasin” is in that char array. Here is what I have tried.

char word[8] = "hassasin";
char Buffer[1000]=sdfhksfhkasd/./.fjka(hassasin)hdkjfakjsdfhkksjdfhkjh....etc 
int k=0;
int t=0; 
int len=0; 
int sor=0; 
for (k=0; k<1000; k++){ 
    for (t=0; t<8; t++){ 
        if (Buffer[k]==word[t]) len++; 
        if (len==8) "it founds 0.9.1" 
    } 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:19:13+00:00Added an answer on June 14, 2026 at 12:19 pm

    if the chararray contains stringend or do not end with \0 you can use these code, because strstr will brake on these ones:

    #include <stdio.h>
    int main()
    {
        char c_to_search[5] = "asdf";
    
        char text[68] = "hello my name is \0 there is some other string behind it \n\0 asdf";
    
        int pos_search = 0;
        int pos_text = 0;
        int len_search = 4;
        int len_text = 67;
        for (pos_text = 0; pos_text < len_text - len_search;++pos_text)
        {
            if(text[pos_text] == c_to_search[pos_search])
            {
                ++pos_search;
                if(pos_search == len_search)
                {
                    // match
                    printf("match from %d to %d\n",pos_text-len_search,pos_text);
                    return;
                }
            }
            else
            {
               pos_text -=pos_search;
               pos_search = 0;
            }
        }
        // no match
        printf("no match\n");
       return 0;
    }
    

    http://ideone.com/2In3mr

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
For example, I have this char *buff = this is a test string; and
Let's say I have a char *example that contains 20 chars. I want to
Following is the example I have reproduced: charName :: Char -> String charName 'a'
I have an example here: int runcmd(char *cmd) { char* argv[MAX_ARGS]; pid_t child_pid; int
I have a string as const char *str = Hello, this is an example
I have a double converted to a unsigned char array. For example for value
I have an array of 4 characters, for example: char char_array[10]; char_arr[0] = 'a';
for example we have map map<char,int>mymap; mymap['a']=101; mymap['c']=45; mymap['b']=76; mymap['d']=98; i know that if
In my code, I have char array and here it is: char pIPAddress[20]; And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.