![]() |
|
#1
|
||||
|
||||
Compiling ErrorsOk, so I'm relatively new to c++ and programming altogether. I just started learning c++ a semester ago. What I'm trying to do now is create a program that will allow me to input a word/sentence/whatever and the program will take that sentence and change some (and eventually all) the characters to a predefined value (ie: change every occurance of the letter 'a' to 'e' ) In my code, I've only set one letter to change for testing purposes. The problem is that I'm getting error messages that I don't understand...
Here's the code that I'm trying to compile... CPP / C++ / C Code:
The Error Messages I'm getting Can Be Viewed Here: ![]() I've tried everything that I can think of, and to no avail. By the way, I'm using a Digital Mars free c++ compiler that I got from my school. How might I fix this, anyone have a clue? I appreciate any help, Todd Whitford ssprodnc.tripod.com |
||||
|
#2
|
|||
|
|||
|
Quote:
Three things: In functions getInput() and translateInput, you treat the argument "a" as pointer to char. So the functions should be something like: CPP / C++ / C Code:
The switch statement should look something like CPP / C++ / C Code:
With these changes, I think it should compile with no errors (I can't check it since I don't have digital mars). You still may have to do some work to get its functionality to be what you want, but once it's running, you can do the debug thing. Regards, Dave |
|
#3
|
||||
|
||||
|
Quote:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#4
|
||||
|
||||
|
Ok, thanks, I appreciate the help, I'll let you know if it works...
|
|
#5
|
||||
|
||||
|
I think what we have here is a mild case of "I don't know what in the world I'm doin'" You see, all that I've really learned so far in the class that I'm in is extremely basic stuff like declaring variables, constants, arrays, various loops, very basic text file manipulation, etc... All straight forward and stuff like that. I've just been bored as that stuff has been so easy for me to pick up, I wanted to do something constructive rather than just finding the average number from some fake company and displaying it in a text file. So, that's what led me to wanting to do this translator....
Now that that is out of the way.... I tried the recommended changes (save for a different compiler, but that's next) and searched the net tirelessly for some help with the errors in compiling that still haunt me... Once again.. Here's my code: CPP / C++ / C Code:
I dunno what this thing is trying to say to me, and my instructor won't return any of my emails.... mabye she's just busy... Anyway, here's my errors: ssprodnc.1800-webhosting.com I'd appreciate any help that can be given, as I need it. And I will try a different compiler immediately to see if that changes anything... Thanks, Todd |
|
#6
|
||||
|
||||
|
Quote:
Quote:
Quote:
1) we don't have to go elsewhere for info 2) we can respond to each error individually 3) It's easier to dissect the error when we can edit it here. The program is barfing on your third parameter in your getInput() call. You prototype your function as CPP / C++ / C Code:
CPP / C++ / C Code:
*i has been changed to protect the formatting __________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#7
|
||||
|
||||
|
There is another problem in translateInput; you use j to iterate through the vectors components, but then use i for the switch statement and for the changes done to the vector.
Dave missed it too Quote:
Actually, it should be: CPP / C++ / C Code:
The char thing was also an error, so Dave was right about it. Quote:
Indeed, you probably wanted to pass the vector by address, but instead you created a vector of pointers to char.... Now, since Walt didn't want to give you all the answers, I won't either, unless you really can't figure it out on yourself. Anyway, you should know that if you pass a function the name of a vector, it will pass the address of the first element of the vector (it's the same as &a[0]). Also, the vector's elements are stored one after another in memory. Enough already! The good news is that I got your program running - now you try it! Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#8
|
||||
|
||||
|
Ok, firstly...
Quote:
Quote:
Quote:
So I first started by declaring a[] as a 50 char array. That's what it is an array of characters (or at least what its supposed to be). What it should do from here is get passed to the getInput function... CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
In the translateInput function, I'm using the variable j as a counter comparing its value to the i counter so it'll stop trying to translate the values of my array a[]. By the way, thanks LuciWiz for pointing out that I had the i in the switch, not the j. It would've taken a while to figure that out, once I got the program working... CPP / C++ / C Code:
So from here, I would like for the array a[] which has now been filled according to the variable i with fully translated characters, to be sent back to the main function for yet one more action. Here, it should be sent, along with my good buddy i to the displayResult function... CPP / C++ / C Code:
In this function, I'm using a j variable again to act as a counter against i to display each of the values (characters) in my array a[] . From here, the program should just go back to the main function for some finalization... CPP / C++ / C Code:
That is what this program is supposed to do. Not necessarily what the code says it'll do. So as far as: Quote:
I guess my real question is probably regarding passing around arrays. I never learned that in class... I think the instructor may have written that down on the board the day of the final exam, but I was too busy trying to leave that place to get home Anyway, I'll put up all the code once more, so that it'll be formatted correctly. Sorry to bother everyone with these problems as I'm sure there are more pressing needs on the forum than my own... CPP / C++ / C Code:
OH yeah, I'll put the errors in manually as well :-) Code:
Thanks for all the help... everyone.. in past replies, and future ones as well!! Later, Todd SAFM Irregularly Regular Person |
|
#9
|
||||
|
||||
|
Yes, the tag is OK, so is the formatting.
Anyway, I guess by your post you say you had no luck in following our directions? As promissed, I will give you my version of the program. You probably had something in mind, but I can't figure out right now how to change your program to better suit your original idea. Here is my code (yours, actually, with minor modifications): CPP / C++ / C Code:
My code is VC .NET compliant, so you'll have to probably delete the stdafx.h include, and change the name of the main method to ... main The rest should be allright for your compiler too. In case you have trouble following my code, or want a different solution, please post back and we'll do our best to help you. Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#10
|
||||
|
||||
|
I appreciate the help, and I'll try out your version as soon as I get the time. I think I'm still going to try to work out the flaws with my code first, as I don't want to just give up on it... That would'nt work to well with Chivalry (I've been kinda on this big thing lately about following the old code). Anyway, your help is respected, and I'll try some different compilers... Mabye the problem's just with this old Digital Mars piece.
Thanks... Todd SAFM Irregularly Regular Person |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can we trap errors in Constructors (C++) | Poolan | C++ Forum | 6 | 19-Nov-2004 08:41 |
| help to debug complier errors | nkhambal | C Programming Language | 3 | 04-Oct-2004 09:26 |
| Wierd errors (again) | crystalattice | C++ Forum | 3 | 15-Aug-2004 21:02 |
| kernel compiling & Geforce updating | crystalattice | Computer Software Forum - Linux | 5 | 16-Jun-2004 08:38 |
| Can somebody look at this and point out any errors to me | soulfly | C Programming Language | 7 | 31-Mar-2004 10:45 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The