![]() |
| ||
| C++ program help 1 Attachment(s) I need help with errors I am getting with my program that is suppose to take in lines of text and out put the number of letters to the user. I have a lot these errors Quote:
|
| ||
| Re: C++ program help void conversion (int size, char lines [Max_Lines][Max_Size], char alphabet[27] = "abcdefghijklmnopqrstuvwxyz", int alphacount [27] = 0);Remove the { and } around the default parameters. That will cause the int array to be NULL pointers if the calling function doesn't supply the array. For example int foo(int ary[4] = 0) |
| ||
| Re: C++ program help Check your variable typing (i.e. Max_Lines instead of Max_Line in line 66 but I also read countAlpha instead of alphacount elsewhere). Also, you should pass lines as argument to the function displayTable. You have an out-of-boundaries access for your lines array - be careful how you play with size <= Max_Linesand how you declared lines itself char lines [Max_Lines][Max_Size];. Notice that lines is also accessed in displayTablefunction at line 92 if(!isalpha(lines[n][z])). Ask yourself: what value does n has? EDIT: Imho it's better to post your code with the help of code tags instead of providing it as an attachment for programs of this size - but this is just a suggestion |
| ||
| Re: C++ program help First I would like to say thanks to everyone's help I have cut down my errors tremendously. Second I am really struggling with this class and I am now at the point to where I'm just trying to pass and leave with the little bit of knowledge I've gained. That being said some of the advice given is beyond me, and though I'm sure you covered these error codes already here is what I'm getting specifically. Quote:
|
| ||
| Re: C++ program help You should remove default values for default arguments from your functions definitions. For example this code #include <iostream> Would result in the following compile errors: test.cpp: In function ‘int myfunction(int, int)’: while this code (without " = 2 " default value in function definition) #include <iostream> will compile fine |
| ||
| Re: C++ program help Hey thanks I got it to compile and run, one obstacle done now to the next, lol. For some reason its not counting the letters correctly in the lines of text i type? I believe that would have something to do with the conversion function or maybe not reading in all the lines of text. Any help would be appreciated. void readLine (char letter[][Max_Size], int Max_Lines, int& size) void conversion (int size, char lines [Max_Lines][Max_Size], char alphabet[27], int alphacount [27]) |
| ||
| Re: C++ program help Thanks everyone I got it working correctly PS: I should have come here for help earlier in my semester |
| All times are GMT -4. The time now is 12:15 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC