sorry i didnt mention it before but the user enters the word (so i dont need a dictionary)
getting the code in 1 string is where im going wrong this is what im ending up doing all the time...
gets(a) //a is an array
for(int i=0;i<10;++i)
for(int j=0;j<10;++j)
b[i][j]=a[i]; /*trying to store it in many lines but this might be where im going wrong*/
for(i=0...)
for(j=0...)
cout...
User Profile
Collapse
-
Counting the number of times a word occurs in a 2-D array of strings in C++
I want to write a function in C++ to accept a 2D array of STRINGS and a word then count the number of times the word occurs in a string.
Tried different codes but end up with too many errors! Am I supposed to store the 2D array in a 1D array word by word (cant figure out how) or check for the word line by line? -
nvm got it
corrections: (under main)
int n, a[10];
cin>>n;
for(int i=0;i<n;++i)
cin>>a[i];
cout<<is_sorted (a,n)
getch();
}Leave a comment:
-
how to get rid of Illegal structure operation?
The question is to write C++ program using a function ( is_sorted() ) which takes a 1-D array and size as arguments, returns 1 if it is in ascending order, -1 if in descending order or else 0.
I used int* a[10]; as i was getting an error with just int a[10] when calling the function, can anyone explain to me why i need int* and mostly how to get rid of the illegal structure operation?
This is my code:
#
int is_sorted(int...
No activity results to display
Show More
Leave a comment: