![]() |
|
#1
|
|||
|
|||
Calling functionsI have this 3 function i want to call them in main. I did but i dont know whetever my parameters are correct or not cause it gives me arrays saying i cant convert parameter. I think my logic is wrong but i dont know where PLEASE help to corret it. Thank You.
CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
If you are getting compile errors, you need to tell us EXACTLY what the messages are (copy them into your post) and add a comment on the lines in the posted code so we can find the lines in question.
In your Copy String function, you are attempting to copy the literal text "swetha" over the literal text "harsha". This is illegal. If you could do this, everywhere you use the literal "harsha" after the call, "swetha" will be used instead. This would be very confusing. To illustrate the problem consider this function: CPP / C++ / C Code:
Call with this main: CPP / C++ / C Code:
Same type of problem with Join String. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#3
|
|||
|
|||
|
I m sorry i know i cant past string "harsha" n "swetha" like that. I made a mistake. I have correct it. I have do the correction for it by user entering the string. But i still have the error saying "'copystring' : cannot convert parameter 1 from 'char [30]' to 'char' ". I dont understand what error this means. If I have any logic mistake please correct me. Thank you.
CPP / C++ / C Code:
|
|
#4
|
||||
|
||||
|
Hi harsha. I got this to compile as is, but there are some problems. Take a look at your function declarations:
CPP / C++ / C Code:
I am not sure why you even have them. You don't need to declare your functions unless they are called previous to there definition. One other thing that my compiler didn't like and probably something to get used to. main should not be void, it should always return an int value. Most O/Ses that I have used will take care of this, but a process should *always* return a value when it finishes. __________________
The best damn Sports Blog period. |
|
#5
|
|||
|
|||
|
Thx for your reply but when i do as u ask me to:
CPP / C++ / C Code:
I still get an error saying " conditional expression of type 'void' is illegal" 'int __cdecl comparestring(char *,char *)' : overloaded function differs only by return type from 'void __cdecl comparestring(char *,char *)' 'comparestring' : redefinition; different basic types Why i need to declare this is for passing parameters cause without these declaration i can't pass two parameters. |
|
#6
|
||||
|
||||
|
Hi Harsha. Did you just add the comments? You need to replace those lines so they are:
CPP / C++ / C Code:
And I still say that you can just remove these lines all together. They are not necessary as your main function is after all of your other function implementations. Alot of people like to explicitly define functions like this, but if it is not needed, I just think it makes another area, where you can have a typo... ![]() __________________
The best damn Sports Blog period. |
|
#7
|
|||
|
|||
|
Thanks a lot it works now. I just forgot to replace the void with int.
You ask to remove the lines right, I cant do that cause when i do so it gives me an error no declaration of these functions. So I need these 3 lines to call the functions. Can i ask you what is "typo"? |
|
#8
|
||||
|
||||
|
Quote:
Sorry "typo" is an english'ism for typing a mistake. For instance typing "void" instead of "int" ![]() What compiler are you using? My compiler (gcc/g++) doesn't have a problem if I remove the decleration lines. Beyond that, I don't know of any compiler that would have a problem based on the structure of C/C++ programs and the way that they are compiled. What errors do you get if you comment out or remove those lines? __________________
The best damn Sports Blog period. |
|
#9
|
|||
|
|||
|
I get this errors when i remove the lines:
error C2065: 'copystring' : undeclared identifier : error C2065: 'joinstring' : undeclared identifier : error C2065: 'comparestring' : undeclared identifier : error C2373: 'copystring' : redefinition; different type modifiers error C2373: 'joinstring' : redefinition; different type modifiers : error C2373: 'comparestring' : redefinition; different type modifiers I use Micrososft Visual C++ to do my codings. |
|
#10
|
||||
|
||||
|
Quote:
hmmm. I just dusted off V.C. 6.0 and compiled this: CPP / C++ / C Code:
with no errors or warnings. Is that exactly the way that you had it? It is not a big deal as long as it is working, but I *never* pre-declare my functions unless I need to. I have never had a problem with this on any compiler since I started using C. My main function is always the last function though... __________________
The best damn Sports Blog period. |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| conflict between printf and stdarg.h va functions | mirizar | C Programming Language | 3 | 12-Jul-2004 09:11 |
| Understanding functions | tommy69 | C Programming Language | 15 | 15-Mar-2004 18:59 |
| Calling functions within a function | spudtheimpaler | C Programming Language | 5 | 02-Mar-2004 09:02 |
| New to C...need help calling functions | rbeierle | C Programming Language | 3 | 10-Feb-2004 19:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The