help with substring in c programing

Ads
 

help with substring in c programing

Hi I could not found programming in C in the "select category" so I am posting my question in java section. Please help with substring function,prompt the user for two strings and display whether or not the second string is a substring of the first string.

Regards

View Answers

March 10, 2011 at 5:25 PM

#include<stdio.h>
#include<conio.h>

void main()
{
char str[80],sub[10];    
int count1=0,count2=0,i,j,flag;

clrscr();

puts("Enter a string:");
gets(str);

puts("Enter search substring:");
gets(sub);

while (str[count1]!='\0')
count1++;

while (sub[count2]!='\0')
count2++;

for(i=0;i<=count1-count2;i++)
{
for(j=i;j<i+count2;j++)
{
flag=1;
if (str[j]!=sub[j-i])
{
flag=0;
break;
}
}
if (flag==1)
break;
}
if (flag==1)
puts("Substring is found!");
else
puts("Substring does not found!");
getch();
}

March 11, 2011 at 2:13 AM

thank you for your help, but when I run the program in eclipse, I get the error message " implicit declaration of function clrscr().

Ads









Related Tutorials/Questions & Answers:
help with substring in c programing
help with substring in c programing  Hi I could not found programming in C in the "select category" so I am posting my question in java section. Please help with substring function,prompt the user for two strings and display
C++ programing
C++ programing  how to change constants to be randomly generated
Advertisements
c programing
c programing  Write 2 implementations of C's string copy routine, one with a loop and the other using recursion. What is the security risk with this routine? The function should have the signature: char* strcpy(char* destination
c programing
c programing  Write 2 implementations of C's string copy routine, one with a loop and the other using recursion. What is the security risk with this routine? The function should have the signature: char* strcpy(char* destination
C Programming SubString Program
C Programming SubString Program  Sir I want to Check whether the Single Substring is present in the given 3 string. characters. eg if i entered... will be TRUE. Plz Help Me
SubString help - Java Beginners
SubString help  Hi , I would appreciate if somebody could help me... a substring of 35 zeros '00000000000000000000000000000000000' and they could... substring . If it find 35 zeros i need 10 digits in front of it along with those
Java programing help
Java programing help  Can you help me create this program? Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign
C String Substring
C String Substring       In this section, you will learn how to get the substring from a string in C. You can see in the given example, a string and a method substring
guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays
C Program....PLEASE HELP
C Program....PLEASE HELP  For this assignment, you are to write a program that calculates points along a rhodonea curve, a.k.a. a mathematical rose..., and pointers. I am lost and need a little help starting please *int fillArray
Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming. this is my code... i'm using Turbo C++. It's showing so many errors!.. I don't know what to do. Please help!! #include<iostream.h> void main
C++ Starter needs help :S
C++ Starter needs help :S  Hi, im 15 & im trying to learn how to program, i am starting with C & C++ since these are (what ive been told... questions abaut C++. Please help! :(   Please visit the following link: C
programing
Hello if anyone can help I would like to know why I get this error when executing
hi need help with C++ programming!
hi need help with C++ programming!  how do i : b. Store numbers / characters into the file (output) c. Retrieve numbers / characters from the file...; "Unable to open file"; return 0; } c) #include <iostream> #include <
C get Substring from String
C get Substring from String       This section illustrates you how to get the substring using library function. You can see in the given example, we have used the library
Java programing
Java programing   need help wrting this Write a program that has an array of 5 Strings, and determines which ones are palindromes (letter-case does not matter). thanks
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?  Hello to all, I...() which is used in c/c++. In some sites i found using the Runtime.xxxx.xxx(command
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT  I WANT TO KNOW ABOUT THE JAVA SOCKET PROGRAMING FROM BASIC LEVEL AND HOW CAN I WORK ON IT I KNOW THE JAVA PROGRAMING.SO PLEASE HELP ME HOW CAN I DO SOCKET PROGRAMING
c programming
c programming  write a program to input five numbers by using while loop in c programing
find and substring
find and substring   **import java.io.BufferedReader; import... String"); String findstring = keybord.readLine(); String substring = keybord.readLine(); findreplace(findstring,substring); } catch(IOException io
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... clock to measure the running time c) Use several input (eg: N = 100 , N = 1000.... Implement the code and give the running time for several values of N c. Compare your
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... clock to measure the running time c) Use several input (eg: N = 100 , N = 1000.... Implement the code and give the running time for several values of N c. Compare your
socket programing in servlet
socket programing in servlet  give me a example to write socket programing in servlet
C++
C++  I have been asked to write a programme that gets five values,gets the sum,average and product please help me
programing
programing
programing
programing
programing
programing
programing

Ads