Hello. I have to find out whether a word is made up of the same letters with another word. For example: "car" and "arc" are good because they are made up of the letters 'a','c','r' while the words "bang" and "wang" are not good because 'w' is not int the word "bang".
#include<iostream>
#include<cstring>
using namespace std;
string a,b;
int main(){
int n,m;
getline(cin,a);
getline(cin,b);
m=a.length();
n=b.length();
int i=-1,j;
int found;
Please use [code] tags -- it is very difficult to read your code like that.
The main problem with your algorithm is with the condition in your do..while loop.
What you are trying to do is check to see if every letter found in one is the same as the letter found in another.
So if the first letter in a[] is anywhere in b[], then 'found' will be true. If a[] and b[] really are anagrams, then 'found' should always be true. It is when it is not true that you have learned something.
Also, i==m is only true at the end of the loop. I think you'd rather continue while i!=m, right?