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 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().









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
Programing Help - Java Beginners
Programing Help  how to design a filebrowser in java "witout using Swing
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 Programing - CVS
C Programing  Write a C Program to display the following menu: Menu 1. Display 2. Copy 3. Append 4. Exit Accept the choice (1-4) from the user, and perform the following tasks: Choice 1: Accept a file name from the user
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
C Help - Development process
C Help  Dear sir, I'm developing a program in c using TURBO-C, i want that when my program runs the console window(cmd) should be hidden. program should run in task manager. thnx
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
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 <
programing
Hello if anyone can help I would like to know why I get this error when executing
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
help me on jstl- <c:url> - JSP-Servlet
help me on jstl c:url  what is jstl in java
Substring in java
Substring in java   example:output 0f the code.. Input String:University of the Cordilleras Input Substring:of Output:1 ...use non static methods,don't use (.Substring).. ..please help me.. ..thank you.. deadline:November
Substring in java
Substring in java   example:output 0f the code.. Input String:University of the Cordilleras Input Substring:of Output:1 ...use non static methods,don't use (.Substring).. ..please help me.. ..thank you.. deadline:November
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
programing question
programing question  how do i use loops(for,while) to add components in java   Hi Friend, The below code might help you.ADS_TO_REPLACE_1 import java.awt.*; import javax.swing.*; class TextFieldArray extends JFrame
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
c programming
c programming  write a program to input five numbers by using while loop in c programing
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
programing
programing
programing
programing
programing
programing
programing
programing
programing
ModuleNotFoundError: No module named 'substring'
ModuleNotFoundError: No module named 'substring'  Hi, My Python... 'substring' How to remove the ModuleNotFoundError: No module named 'substring' error? Thanks   Hi, In your python environment you
C++
C++  I have been asked to write a programme that gets five values,gets the sum,average and product please help me
How to substring in Java?
How to substring in Java?  Hi, I want to get a part of String in Java. How to substring in Java? Thanks   HI, Hi you can use the substring() method of Java for getting a part of string based on the index number
programing - IoC
programing  write 4 integers . in that print smalest integer and largest integer  Hi friend, Code to help in solving the problem : import java.io.*; class NumberExample { public static void main(String[] args
programing - WebSevices
programing  write a program that ask the user to input 4 integers. the program print the smallest and biggest number. the folowing is the sample out put  Hi friend, Code to help in solving the problem : import
C++
C++  How can i write this in dev c
C++
C++  How can i write this in dev c
c#
c#  how to find out the size of the BMP image in C
String substring(int beginIndex)
String substring(int beginIndex)   ... the substring(int beginIndex) method of String class. We are going to use substring(int beginIndex) method of String class in Java. The description of the code
Java Substring
Java Substring In this section we will read about Java Substring. A part of String is called substring. Substrings are also a String. Substring is used..., how they can find the substring. To find the substring in Java there is method
c++
c++  use a prgrm as an example to xplain-: a)class b)object c)message d)cope resolution operator

Ads