Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,959 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,590 people online right now. Registration is fast and FREE... Join Now!




string function that counts

 
Reply to this topicStart new topic

string function that counts

lex_12
10 May, 2008 - 07:37 AM
Post #1

New D.I.C Head
*

Joined: 7 May, 2008
Posts: 5

I an just looking for a string function/function that can count the number of same characters in two inputs(eg. string 1 and string 2). Does anybody have an idea?
User is offlineProfile CardPM
+Quote Post

realNoName
RE: String Function That Counts
10 May, 2008 - 10:37 AM
Post #2

D.I.C Regular
***

Joined: 4 Dec, 2006
Posts: 299



Thanked: 5 times
My Contributions
Post the code you have so far using the code tags: code.gif We can't help you if you don't post your code. We will not do your homework for you. You MUST show some effort.
User is offlineProfile CardPM
+Quote Post

lex_12
RE: String Function That Counts
10 May, 2008 - 09:40 PM
Post #3

New D.I.C Head
*

Joined: 7 May, 2008
Posts: 5

CODE


#include<stdio.h>
#include<string.h>


main(){

    char str1[30];
    char str2[30];
    int x;

    printf("Enter a name: \n");
    gets(str1);


    printf("Enter another name: \n");
    gets(str2);

    
        x = ((strlen(str1) + strlen(str2)) % 6;//I would like to posiibly know a string function or any other     
        way that counts the number of same character and to replace this part here.//

        switch(x){
            case 0:printf("Sweethearts\n");
        break;
            case 1:printf("Lovers\n");
        break;
            case 2:printf("Anger\n");
        break;
            case 3:printf("Marriage\n");
        break;
            case 4:printf("Enemies\n");
        break;
            case 5:printf("Friends\n");
        break;
        }
  
    
}


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:25AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month