#include <iostream>
#include <string>
/*i want to compare string and char as char is a subset of string*/
string S [50];
//algorithm is somewhat like:
i=0;
while(i<23){
char c = (char) i;
S[i] = c;
}
for(i=23;i<50;i++){
S[i]="hello";
}
//i want to check how many hello are there
i=0;
x=0;
while(i<50){
if (S[i] = "hello"){
x++;
i++;}
else{
i++;
}
//but here is one problem the array elements from 0 to 22 are characters so it cant be compared
//with hello which is a string. to do so i have to convert those characters into strings.
//code would be somewhat
i=0;
while(i<23){
c = char(i)
//convert c which is a character into string
S[i] = c;
}
Vivek_12 0 Newbie Poster
NathanOliver 429 Veteran Poster Featured Poster
ravenous 266 Posting Pro in Training
Vivek_12 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.