answersLogoWhite

0


Best Answer

#include #include intsearch(char[],char[]); void main() { char a[100],b[40]; int loc; printf("\n Enter the main string :"); gets(a); printf("\n Enter the search string :"); gets(b); loc = search(a,b); if(loc==-1) printf("\nNot found"); else printf("\nFound at location %d",loc+1); getch(); } int search(char a[],char b[]) { int i,j,k; i=0,j=0; while(a[i]!='\0') { while(a[i]!=b[0] && a[i]!='\0') i++; if(a[i]=='\0') return(-1); //search can not continue k=i; while(a[i]==b[j] && a[i]!='\0' && b[j]!='\0') { i++; j++; } if(b[j]=='\0') return(k); if(a[i]=='\0') return(-1); i=k+1; j=0; } }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Substring in c without string functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Do I need to write a program to find a substring in a given string in c plus plus?

No.


What is substr function does in c?

it will give the substring of length(as per the user) from the actual string,and the starting length from where it has to copy the substring from actual should be given by the user.


How to capitalize the first letter of a string without using built in C functions?

jst subtract 32 from first character of string to convert it into capital


What is string library functions syntax?

String library function is one which is used to perform an operation in C-programming,without which library functions likestrlen(),strcp(),strcmp(),strdup(),strrev(),etc..,.can be performed


C plus plus library functions for string operations?

You can use "string" class in C++ for string operations or you may use c style string functions as well. #include <string> String class in C++ provides all basic function to operate on strings. you may details descriptin at http://www.cplusplus.com/reference/string/string/


What are the functions of Atoi itoa and gcvt in C language?

All these are conversion functions - atoi()-string to integer.itoa()-integer to string.gcvt()-double to string


What is the importance of using functions in a c program?

C programs do not function without functions.


Library functions in C programming?

They are very important. The most commonly used functions are the string and file handling ones.


Explain different string functions handled in c sharp?

C#:String FunctionsThe methods and properties of the String type include:String s="Sourav was here"Example Value Detailss+" once" "Sourav was here once" The strings are concatenated using +s.Equals("another") false Also s == "another" Tests for equalitys.IndexOf("was") 6 Returns -1 if the substring isnot there.s.Length 14 The number of characterss.Split(" ") ["Andrew","was","here"] Returns an array of String.s.Substring(2,7) "urav wa" Characters from position 2. 7characters are takens.ToUpper() "SOURAV WAS HERE" Also .toLowerCase()


Diff between string and array?

String and array are not related to one another so they have many differences. a. A string is used to hold alpha numeric values inside it b. An Array is used to hold multiple values of any primitive data type c. A String has operations like equals, concatenate, substring etc whereas an array does not have them d. You can iterate through an array but we cannot iterate through a string.


How can a string be converted into a number in c?

With functions like sscanf, strtol, strtoul, atoi, atof etc.


What are the different built in string functions in JavaScript?

String functions are the set of functions that we generally need while playing with strings like: strlen - finds length of the string strcat - for concatenation strcpy - for copying strcmp - for comparing, etc. Thanks