Finding first/last occurrence of a character in a string
without using strchr( ) /strrchr( ) function.

Answer Posted / sepideh

#include<iostream>
#include<conio.h>
using namespace std;
int main(){
char m[20];
char x;
gets(m);
x=getch();
for(int i=0;i!=null;i++)
if(m[i]==x){
cout<<i;}
getch();}

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we print only part of a string in c?

801


Write a program to print "hello world" without using a semicolon?

818


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1509


How can a number be converted to a string?

885


Where are some collections of useful code fragments and examples?

938


Are c and c++ the same?

790


How do you print an address?

968


Is file a keyword in c?

677


What is integer constants?

787


Does c have function or method?

789


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

834


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1728


What is clrscr ()?

847


general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only

819


What does c mean?

762