Author |
Message |
jeff #1 / 8
|
 int to int array problem
Hello, how due I get the output of int srt into arrsrt[30]? int srt=0; int arrsrt[30]; char alph[30]="abcdefghijklmnopqrstuvwxyz"; cout<<alph<<endl; for(int m=0;m<30;m++) srt=count(arry,arry+550,alph[m]); // this counts charactors a thru z arrsrt[30]=srt; // this line in trouble! } cout<<arrsrt; thank you jeff
|
Tue, 15 Apr 2003 12:47:52 GMT |
|
 |
Roger Onslo #2 / 8
|
 int to int array problem
There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] .. remember that array indices start from 0. -- Roger Onslow Software Developer See my articles at http://www.codeguru.com See the product I am working on at http://www.swishzone.com "Operator .. give me the number for 911" .. Homer Simpson
Quote: > Hello, how due I get the output of int srt into arrsrt[30]? > int srt=0; > int arrsrt[30]; > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > cout<<alph<<endl; > for(int m=0;m<30;m++) > srt=count(arry,arry+550,alph[m]); // this counts charactors a > thru z > arrsrt[30]=srt; // this line in > trouble! > } > cout<<arrsrt; > thank you > jeff
|
Tue, 15 Apr 2003 14:05:50 GMT |
|
 |
jeff #3 / 8
|
 int to int array problem
Hi, regardless of the size of the array, my out put is 006BF698 repeate oer size of array.When I "cout" just the count algorithm it counts all letters of paragraph a to z. Something is happening when I try to take the output which is of type integer and try to put it into type integer array. I plan on count capital letters if I can get this to work or use the " tolower" function to make everything lower case . jeff Quote: ----- Original Message -----
> There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] .. > remember that array indices start from 0. > -- > Roger Onslow > Software Developer > See my articles at http://www.codeguru.com > See the product I am working on at http://www.swishzone.com > "Operator .. give me the number for 911" .. Homer Simpson
> > Hello, how due I get the output of int srt into arrsrt[30]? > > int srt=0; > > int arrsrt[30]; > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > cout<<alph<<endl; > > for(int m=0;m<30;m++) > > srt=count(arry,arry+550,alph[m]); // this counts charactors a > > thru z > > arrsrt[30]=srt; // this line in > > trouble! > > } > > cout<<arrsrt; > > thank you > > jeff
|
Wed, 16 Apr 2003 01:28:52 GMT |
|
 |
Joe Delekt #4 / 8
|
 int to int array problem
Greets, That's because you are doing something other than you expect. By just using "cout << arrsrt << endl;" you are sending the address of the int arrsrt[] array to the output stream. If you want to display all the elements, you must loop through them and display them individually. (i.e. "cout << arrsrt[0] << arrsrt[1] << /* etc.... << */ endl;" Regards, Joe
Quote: > Hi, regardless of the size of the array, my out put is 006BF698 repeate oer > size of array.When I "cout" just the count algorithm it counts all letters > of paragraph a to z. > Something is happening when I try to take the output which is of type > integer and try to put it into type integer array. I plan on count capital > letters if I can get this to work or use the " tolower" function to make > everything lower case . > jeff > ----- Original Message -----
> > There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] .. > > remember that array indices start from 0. > > -- > > Roger Onslow > > Software Developer > > See my articles at http://www.codeguru.com > > See the product I am working on at http://www.swishzone.com > > "Operator .. give me the number for 911" .. Homer Simpson
> > > Hello, how due I get the output of int srt into arrsrt[30]? > > > int srt=0; > > > int arrsrt[30]; > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > cout<<alph<<endl; > > > for(int m=0;m<30;m++) > > > srt=count(arry,arry+550,alph[m]); // this counts charactors a > > > thru z > > > arrsrt[30]=srt; // this line in > > > trouble! > > > } > > > cout<<arrsrt; > > > thank you > > > jeff
|
Wed, 16 Apr 2003 01:37:38 GMT |
|
 |
jeff #5 / 8
|
 int to int array problem
Hello, I added the a for loop to cout<<arrsrt[j]; and still get garbage here is the whole program with out put. thanks jeff #include<iostream> #include<fstream> #include<string> #include<algorithm> using namespace std; int main() { char arry[600]; float chcount=0; float wdcount=0; float sencount=0; char ch='|'; string str="Any experianced programmer engaged in writing programs" " for use by others knows that, once his program is working correctly" ", good output is a must. Few people really care how much time and trouble" " a programmer has spent in designing and debugging a program." " Most people see only the results. Often, by the time a programmer" " has finished tackling a difficult problem, any output may look" " great. The programmer knows what it means and how to interpret" " it. However, the same cannot be said for others, or even for the" " programmer himself six months hence."; ofstream outfile("test.txt"); for(int i=0;i<str.size();i++) outfile.put(str[i]); cout<<"\nfile written\n"; outfile.close(); ifstream infile("test.txt"); while (infile.get(ch)) { if(ch==' ') wdcount++; else chcount++; if(ch=='.') sencount++; } infile.close(); ifstream ninfile("test.txt"); ninfile.getline(arry,600); cout<<arry<<endl; cout<<"\nfile read\n"; cout<<"word count"<<wdcount<<endl; cout<<"sentence count"<<sencount<<endl; cout<<"character count"<<chcount<<endl; float avews=wdcount/sencount; cout<<"average words in a sentence "<<avews<<endl; float aveltsen=chcount/wdcount; cout<<"average letters in a word "<<aveltsen<<endl; int srt=0; int arrsrt[40]; char alph[30]="abcdefghijklmnopqrstuvwxyz"; cout<<alph<<endl; for(int m=0;m<30;m++) { srt=count(arry,arry+550,alph[m]); arrsrt[40]=srt; } for(int j=0;j<40;j++) { cout<<arrsrt[j]; } return 0; Quote: }
***************** OUTPUT************** file written Any experianced programmer engaged in writing programsfor use by others knows th at, once his program is working correctly, good output is a must. Few people rea lly care how much time and trouble a programmer has spent in designing and debug ging a program. Most people see only the results. Often, by the time a programme r has finished tackling a difficult problem, any output may look great. The prog rammer knows what it means and how to interpret it. However, the same cannot be said for others, or even for the programmer himself six months hence. file read word count92 sentence count6 character count457 average words in a sentence 15.3333 average letters in a word 4.96739 abcdefghijklmnopqrstuvwxyz -858993460-858993460-858993460-858993460-858993460-858993460-858993460-85899 3460 -858993460-858993460-858993460-858993460-858993460-858993460-858993460-85899 3460 -858993460-858993460-858993460-858993460-858993460-858993460-858993460-85899 3460 -858993460-858993460-858993460-858993460-858993460-858993460-858993460-85899 3460 -858993460-858993460-858993460-858993460-858993460-858993460-858993460-85899 3460 Press any key to continue
Quote: > Greets, > That's because you are doing something other than you expect. By just > using "cout << arrsrt << endl;" you are sending the address of the int > arrsrt[] array to the output stream. If you want to display all the > elements, you must loop through them and display them individually. (i.e. > "cout << arrsrt[0] << arrsrt[1] << /* etc.... << */ endl;" > Regards, > Joe
> > Hi, regardless of the size of the array, my out put is 006BF698 repeate > oer > > size of array.When I "cout" just the count algorithm it counts all letters > > of paragraph a to z. > > Something is happening when I try to take the output which is of type > > integer and try to put it into type integer array. I plan on count capital > > letters if I can get this to work or use the " tolower" function to make > > everything lower case . > > jeff > > ----- Original Message -----
> > > There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] .. > > > remember that array indices start from 0. > > > -- > > > Roger Onslow > > > Software Developer > > > See my articles at http://www.codeguru.com > > > See the product I am working on at http://www.swishzone.com > > > "Operator .. give me the number for 911" .. Homer Simpson
> > > > Hello, how due I get the output of int srt into arrsrt[30]? > > > > int srt=0; > > > > int arrsrt[30]; > > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > > cout<<alph<<endl; > > > > for(int m=0;m<30;m++) > > > > srt=count(arry,arry+550,alph[m]); // this counts charactors > a > > > > thru z > > > > arrsrt[30]=srt; // this line in > > > > trouble! > > > > } > > > > cout<<arrsrt; > > > > thank you > > > > jeff
|
Wed, 16 Apr 2003 04:29:52 GMT |
|
 |
Joe Delekt #6 / 8
|
 int to int array problem
Greets, Well, for starters, you are setting element 40 of arrsrt[], which is beyond the bounds of the array. Quote: > arrsrt[40]=srt;
That compounded by the fact that I don't even know what srt is, since there is no indication of the definition of the "count()" function in the source provided. Second, I don't see you initializing any of the valid elements of the arrsrt[] array to anything, so in a debug build, they are most likely filled with 0xcccccccc. (And yes, they will all have the same large negative value.) I just checked, and amazingly enough, -858993460 is indeed 0xcccccccc in hex. :) Regards, Joe
Quote: > Hello, I added the a for loop to cout<<arrsrt[j]; and still get garbage > here is the whole program with out put. > thanks > jeff > #include<iostream> > #include<fstream> > #include<string> > #include<algorithm> > using namespace std; > int main() > { > char arry[600]; > float chcount=0; > float wdcount=0; > float sencount=0; > char ch='|'; > string str="Any experianced programmer engaged in writing programs" > " for use by others knows that, once his program is working correctly" > ", good output is a must. Few people really care how much time and trouble" > " a programmer has spent in designing and debugging a program." > " Most people see only the results. Often, by the time a programmer" > " has finished tackling a difficult problem, any output may look" > " great. The programmer knows what it means and how to interpret" > " it. However, the same cannot be said for others, or even for the" > " programmer himself six months hence."; > ofstream outfile("test.txt"); > for(int i=0;i<str.size();i++) > outfile.put(str[i]); > cout<<"\nfile written\n"; > outfile.close(); > ifstream infile("test.txt"); > while (infile.get(ch)) > { > if(ch==' ') > wdcount++; > else > chcount++; > if(ch=='.') > sencount++; > } > infile.close(); > ifstream ninfile("test.txt"); > ninfile.getline(arry,600); > cout<<arry<<endl; > cout<<"\nfile read\n"; > cout<<"word count"<<wdcount<<endl; > cout<<"sentence count"<<sencount<<endl; > cout<<"character count"<<chcount<<endl; > float avews=wdcount/sencount; > cout<<"average words in a sentence "<<avews<<endl; > float aveltsen=chcount/wdcount; > cout<<"average letters in a word "<<aveltsen<<endl; > int srt=0; > int arrsrt[40]; > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > cout<<alph<<endl; > for(int m=0;m<30;m++) > { > srt=count(arry,arry+550,alph[m]); > arrsrt[40]=srt; > } > for(int j=0;j<40;j++) > { > cout<<arrsrt[j]; > } > return 0; > } > ***************** OUTPUT************** > file written > Any experianced programmer engaged in writing > programsfor use by others knows th > at, once his program is working correctly, good output is a must. Few people > rea > lly care how much time and trouble a programmer has spent in designing and > debug > ging a program. Most people see only the results. Often, by the time a > programme > r has finished tackling a difficult problem, any output may look great. The > prog > rammer knows what it means and how to interpret it. However, the same cannot > be > said for others, or even for the programmer himself six months hence. > file read > word count92 > sentence count6 > character count457 > average words in a sentence 15.3333 > average letters in a word 4.96739 > abcdefghijklmnopqrstuvwxyz > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 99 > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 99 > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 99 > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 99 > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 99 > 3460 > Press any key to continue
> > Greets, > > That's because you are doing something other than you expect. By just > > using "cout << arrsrt << endl;" you are sending the address of the int > > arrsrt[] array to the output stream. If you want to display all the > > elements, you must loop through them and display them individually. (i.e. > > "cout << arrsrt[0] << arrsrt[1] << /* etc.... << */ endl;" > > Regards, > > Joe
> > > Hi, regardless of the size of the array, my out put is 006BF698 repeate > > oer > > > size of array.When I "cout" just the count algorithm it counts all > letters > > > of paragraph a to z. > > > Something is happening when I try to take the output which is of type > > > integer and try to put it into type integer array. I plan on count > capital > > > letters if I can get this to work or use the " tolower" function to make > > > everything lower case . > > > jeff > > > ----- Original Message -----
> > > > There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] .. > > > > remember that array indices start from 0. > > > > -- > > > > Roger Onslow > > > > Software Developer > > > > See my articles at http://www.codeguru.com > > > > See the product I am working on at http://www.swishzone.com > > > > "Operator .. give me the number for 911" .. Homer Simpson
> > > > > Hello, how due I get the output of int srt into arrsrt[30]? > > > > > int srt=0; > > > > > int arrsrt[30]; > > > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > > > cout<<alph<<endl; > > > > > for(int m=0;m<30;m++) > > > > > srt=count(arry,arry+550,alph[m]); // this counts > charactors > > a > > > > > thru z > > > > > arrsrt[30]=srt; // this line > in > > > > > trouble! > > > > > } > > > > > cout<<arrsrt; > > > > > thank you > > > > > jeff
|
Wed, 16 Apr 2003 04:56:22 GMT |
|
 |
jeff #7 / 8
|
 int to int array problem
Hi, I thought arrsrt[40]=srt; as seen below in for loop initialized array values. Quote: > for(int m=0;m<30;m++) > { > srt=count(arry,arry+550,alph[m]); > arrsrt[40]=srt;
jeff
Quote: > Greets, > Well, for starters, you are setting element 40 of arrsrt[], which is > beyond the bounds of the array. > > arrsrt[40]=srt; > That compounded by the fact that I don't even know what srt is, since > there is no indication of the definition of the "count()" function in the > source provided. > Second, I don't see you initializing any of the valid elements of the > arrsrt[] array to anything, so in a debug build, they are most likely filled > with 0xcccccccc. (And yes, they will all have the same large negative > value.) I just checked, and amazingly enough, -858993460 is indeed > 0xcccccccc in hex. :) > Regards, > Joe
> > Hello, I added the a for loop to cout<<arrsrt[j]; and still get garbage > > here is the whole program with out put. > > thanks > > jeff > > #include<iostream> > > #include<fstream> > > #include<string> > > #include<algorithm> > > using namespace std; > > int main() > > { > > char arry[600]; > > float chcount=0; > > float wdcount=0; > > float sencount=0; > > char ch='|'; > > string str="Any experianced programmer engaged in writing programs" > > " for use by others knows that, once his program is working correctly" > > ", good output is a must. Few people really care how much time and > trouble" > > " a programmer has spent in designing and debugging a program." > > " Most people see only the results. Often, by the time a programmer" > > " has finished tackling a difficult problem, any output may look" > > " great. The programmer knows what it means and how to interpret" > > " it. However, the same cannot be said for others, or even for the" > > " programmer himself six months hence."; > > ofstream outfile("test.txt"); > > for(int i=0;i<str.size();i++) > > outfile.put(str[i]); > > cout<<"\nfile written\n"; > > outfile.close(); > > ifstream infile("test.txt"); > > while (infile.get(ch)) > > { > > if(ch==' ') > > wdcount++; > > else > > chcount++; > > if(ch=='.') > > sencount++; > > } > > infile.close(); > > ifstream ninfile("test.txt"); > > ninfile.getline(arry,600); > > cout<<arry<<endl; > > cout<<"\nfile read\n"; > > cout<<"word count"<<wdcount<<endl; > > cout<<"sentence count"<<sencount<<endl; > > cout<<"character count"<<chcount<<endl; > > float avews=wdcount/sencount; > > cout<<"average words in a sentence "<<avews<<endl; > > float aveltsen=chcount/wdcount; > > cout<<"average letters in a word "<<aveltsen<<endl; > > int srt=0; > > int arrsrt[40]; > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > cout<<alph<<endl; > > for(int m=0;m<30;m++) > > { > > srt=count(arry,arry+550,alph[m]); > > arrsrt[40]=srt; > > } > > for(int j=0;j<40;j++) > > { > > cout<<arrsrt[j]; > > } > > return 0; > > } > > ***************** OUTPUT************** > > file written > > Any experianced programmer engaged in writing > > programsfor use by others knows th > > at, once his program is working correctly, good output is a must. Few > people > > rea > > lly care how much time and trouble a programmer has spent in designing and > > debug > > ging a program. Most people see only the results. Often, by the time a > > programme > > r has finished tackling a difficult problem, any output may look great. > The > > prog > > rammer knows what it means and how to interpret it. However, the same > cannot > > be > > said for others, or even for the programmer himself six months hence. > > file read > > word count92 > > sentence count6 > > character count457 > > average words in a sentence 15.3333 > > average letters in a word 4.96739 > > abcdefghijklmnopqrstuvwxyz > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > 99 > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > 99 > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > 99 > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > 99 > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > 99 > > 3460 > > Press any key to continue
> > > Greets, > > > That's because you are doing something other than you expect. By > just > > > using "cout << arrsrt << endl;" you are sending the address of the int > > > arrsrt[] array to the output stream. If you want to display all the > > > elements, you must loop through them and display them individually. > (i.e. > > > "cout << arrsrt[0] << arrsrt[1] << /* etc.... << */ endl;" > > > Regards, > > > Joe
> > > > Hi, regardless of the size of the array, my out put is 006BF698 > repeate > > > oer > > > > size of array.When I "cout" just the count algorithm it counts all > > letters > > > > of paragraph a to z. > > > > Something is happening when I try to take the output which is of type > > > > integer and try to put it into type integer array. I plan on count > > capital > > > > letters if I can get this to work or use the " tolower" function to > make > > > > everything lower case . > > > > jeff > > > > ----- Original Message -----
> > > > > There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] > .. > > > > > remember that array indices start from 0. > > > > > -- > > > > > Roger Onslow > > > > > Software Developer > > > > > See my articles at http://www.codeguru.com > > > > > See the product I am working on at http://www.swishzone.com > > > > > "Operator .. give me the number for 911" .. Homer Simpson
> > > > > > Hello, how due I get the output of int srt into arrsrt[30]? > > > > > > int srt=0; > > > > > > int arrsrt[30]; > > > > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > > > > cout<<alph<<endl; > > > > > > for(int m=0;m<30;m++) > > > > > > srt=count(arry,arry+550,alph[m]); // this counts > > charactors > > > a > > > > > > thru z > > > > > > arrsrt[30]=srt; // this > line > > in > > > > > > trouble! > > > > > > } > > > > > > cout<<arrsrt; > > > > > > thank you > > > > > > jeff
|
Wed, 16 Apr 2003 05:04:05 GMT |
|
 |
Joe Delekt #8 / 8
|
 int to int array problem
Greets, I'm afraid that you're missing something very fundamental here. First of all, yes, arrsrt[40] is indeed being assigned the value of 'srt'. However, note that on the line above it, you are assigning the result of the function call to count() to the variable 'srt'. As there is nothing going on between those two points in the program and there is no definition for the "count()" function as provided in your source, there is no way to guess as to the value of 'srt' at the time it is assigned to arrsrt[40]. Now, this all does *not* change the fact that you are indexing an invalid element in your arrsrt[] array. You have declared the array as arrsrt[40], which means that you have elements numbered 0 through 39 inclusive. (A total of 40 elements). In that regard, you should only be assigning values to items arrsrt[0] through arrsrt[39]. Now, keep in mind that you are not only setting a value for an element outside the bounds of your array, you are not setting any of the valid elements of that array. In a debug build, the uninitialized items on the stack (or your array elements in this case) are set to the magic number 0xcccccccc by the compiler for the express purposes of noting uninitialized values during debugging. Dumping out all of these elements will indeed give you all the same values. I'm afraid I don't know exactly what you are trying to accomplish, however, it may be beneficial for you to consult a reference with regards to the use of pointers and arrays as well as the differences between the two. Regards, Joe
Quote: > Hi, I thought arrsrt[40]=srt; as seen below in for loop initialized array > values. > > for(int m=0;m<30;m++) > > { > > srt=count(arry,arry+550,alph[m]); > > arrsrt[40]=srt; > jeff
> > Greets, > > Well, for starters, you are setting element 40 of arrsrt[], which is > > beyond the bounds of the array. > > > arrsrt[40]=srt; > > That compounded by the fact that I don't even know what srt is, since > > there is no indication of the definition of the "count()" function in the > > source provided. > > Second, I don't see you initializing any of the valid elements of the > > arrsrt[] array to anything, so in a debug build, they are most likely > filled > > with 0xcccccccc. (And yes, they will all have the same large negative > > value.) I just checked, and amazingly enough, -858993460 is indeed > > 0xcccccccc in hex. :) > > Regards, > > Joe
> > > Hello, I added the a for loop to cout<<arrsrt[j]; and still get garbage > > > here is the whole program with out put. > > > thanks > > > jeff > > > #include<iostream> > > > #include<fstream> > > > #include<string> > > > #include<algorithm> > > > using namespace std; > > > int main() > > > { > > > char arry[600]; > > > float chcount=0; > > > float wdcount=0; > > > float sencount=0; > > > char ch='|'; > > > string str="Any experianced programmer engaged in writing programs" > > > " for use by others knows that, once his program is working correctly" > > > ", good output is a must. Few people really care how much time and > > trouble" > > > " a programmer has spent in designing and debugging a program." > > > " Most people see only the results. Often, by the time a programmer" > > > " has finished tackling a difficult problem, any output may look" > > > " great. The programmer knows what it means and how to interpret" > > > " it. However, the same cannot be said for others, or even for the" > > > " programmer himself six months hence."; > > > ofstream outfile("test.txt"); > > > for(int i=0;i<str.size();i++) > > > outfile.put(str[i]); > > > cout<<"\nfile written\n"; > > > outfile.close(); > > > ifstream infile("test.txt"); > > > while (infile.get(ch)) > > > { > > > if(ch==' ') > > > wdcount++; > > > else > > > chcount++; > > > if(ch=='.') > > > sencount++; > > > } > > > infile.close(); > > > ifstream ninfile("test.txt"); > > > ninfile.getline(arry,600); > > > cout<<arry<<endl; > > > cout<<"\nfile read\n"; > > > cout<<"word count"<<wdcount<<endl; > > > cout<<"sentence count"<<sencount<<endl; > > > cout<<"character count"<<chcount<<endl; > > > float avews=wdcount/sencount; > > > cout<<"average words in a sentence "<<avews<<endl; > > > float aveltsen=chcount/wdcount; > > > cout<<"average letters in a word "<<aveltsen<<endl; > > > int srt=0; > > > int arrsrt[40]; > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > cout<<alph<<endl; > > > for(int m=0;m<30;m++) > > > { > > > srt=count(arry,arry+550,alph[m]); > > > arrsrt[40]=srt; > > > } > > > for(int j=0;j<40;j++) > > > { > > > cout<<arrsrt[j]; > > > } > > > return 0; > > > } > > > ***************** OUTPUT************** > > > file written > > > Any experianced programmer engaged in writing > > > programsfor use by others knows th > > > at, once his program is working correctly, good output is a must. Few > > people > > > rea > > > lly care how much time and trouble a programmer has spent in designing > and > > > debug > > > ging a program. Most people see only the results. Often, by the time a > > > programme > > > r has finished tackling a difficult problem, any output may look great. > > The > > > prog > > > rammer knows what it means and how to interpret it. However, the same > > cannot > > > be > > > said for others, or even for the programmer himself six months hence. > > > file read > > > word count92 > > > sentence count6 > > > character count457 > > > average words in a sentence 15.3333 > > > average letters in a word 4.96739 > > > abcdefghijklmnopqrstuvwxyz > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > > 99 > > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > > 99 > > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > > 99 > > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > > 99 > > > 3460 > -858993460-858993460-858993460-858993460-858993460-858993460-858993460-858 > > 99 > > > 3460 > > > Press any key to continue
> > > > Greets, > > > > That's because you are doing something other than you expect. By > > just > > > > using "cout << arrsrt << endl;" you are sending the address of the int > > > > arrsrt[] array to the output stream. If you want to display all the > > > > elements, you must loop through them and display them individually. > > (i.e. > > > > "cout << arrsrt[0] << arrsrt[1] << /* etc.... << */ endl;" > > > > Regards, > > > > Joe
> > > > > Hi, regardless of the size of the array, my out put is 006BF698 > > repeate > > > > oer > > > > > size of array.When I "cout" just the count algorithm it counts all > > > letters > > > > > of paragraph a to z. > > > > > Something is happening when I try to take the output which is of > type > > > > > integer and try to put it into type integer array. I plan on count > > > capital > > > > > letters if I can get this to work or use the " tolower" function to > > make > > > > > everything lower case . > > > > > jeff > > > > > ----- Original Message -----
> > > > > > There is no arrsrt[30] .. the last element of arrsrt is arrsrt[29] > > .. > > > > > > remember that array indices start from 0. > > > > > > -- > > > > > > Roger Onslow > > > > > > Software Developer > > > > > > See my articles at http://www.codeguru.com > > > > > > See the product I am working on at http://www.swishzone.com > > > > > > "Operator .. give me the number for 911" .. Homer Simpson
> > > > > > > Hello, how due I get the output of int srt into arrsrt[30]? > > > > > > > int srt=0; > > > > > > > int arrsrt[30]; > > > > > > > char alph[30]="abcdefghijklmnopqrstuvwxyz"; > > > > > > > cout<<alph<<endl; > > > > > > > for(int m=0;m<30;m++) > > > > > > > srt=count(arry,arry+550,alph[m]); // this counts > > > charactors > > > > a > > > > > > > thru z > > > > > > > arrsrt[30]=srt; // this > > line > > > in > > > > > > > trouble! > > > > > > > } > > > > > > > cout<<arrsrt; > > > > > > > thank you > > > > > > > jeff
|
Wed, 16 Apr 2003 06:03:51 GMT |
|
|
|