![]() |
|
#1
|
|||
|
|||
regarding main methodhi im new to the whole File I/O thing so is it possible if i do not include the File I/O codes in the main method?
such as i have another method which i did separately from the main method. I'll only invoke this method when i call it in the main. does it work? i mean will it work? example: CPP / C++ / C Code:
|
|
#2
|
||||
|
||||
|
Hello Jerry.
I am not sure what you mean. So far your code is 100% valid as long as you declare you function singleShots as follows: CPP / C++ / C Code:
You can avoid this declaration if you put singleShots above your main function. What is "my codes" going to do? |
|
#3
|
|||
|
|||
|
oh i guess it means it should b ok...coz i thought i need a main method for the File I/O codes...
oh yes i have a couple of errors: CPP / C++ / C Code:
errors: error C2143: syntax error : missing ';' before ':' error C2065: 'file' : undeclared identifier error C2297: '<<' : illegal, right operand has type 'char [8]' error C2297: '<<' : illegal, right operand has type 'char [2]' error C2224: left of '.close' must have struct/union type when i added the 'std::' the syntax error appeared after i compiled...i chked all the syntax there's nothing wrong |
|
#4
|
||||
|
||||
|
Is this at the top of your file?
CPP / C++ / C Code:
Also, I have found in C++ files that if you include CPP / C++ / C Code:
Quite frankly, I am not a great c++ programmer. I mostly use C style programming. If you are still gettin errors, why don't you post the entire thing. If it is long, you can post it as an attachment. |
|
#5
|
|||
|
|||
|
i included both files
CPP / C++ / C Code:
if i included the namespace thing, the compiler cant identify it. i dont know why. it will give me an error: undeclared identifier. yeah my codes are long. mayb i should just attach it n you take a look...it's ok if you cant solve it too...it's such a headache! |
|
#6
|
||||
|
||||
|
Jerry, what compiler are you using? This is a basic C file (it has a .c extension and most of it seems to be standard c). Is there a reason that you are adding the single_shot function using c++ syntax?
The gcc compiler for example will compile the program based upon the extension (.c is c, .cpp is c++). Basically if this is getting compiled as a c file, what you have added will not work. |
|
#7
|
|||
|
|||
|
really??? oh gosh....ok...so this means i should change all the codes into c? or just change the compiler? oh my....i've been spending time on it like....for so many weeks!
|
|
#8
|
||||
|
||||
|
dsmith suggested
CPP / C++ / C Code:
You included: CPP / C++ / C Code:
Do you notice a difference? Try dsmith's suggestion again. |
|
#9
|
||||
|
||||
|
Quote:
Jerry, if it were me I would code it in C syntax to begin with. ![]() Anyway, what compiler are you using. Are you telling it to compile as a c++ program? A c program can be compiled as a c++ program, but not vice a versa. Also, just for semantics you should change the extension to .cpp ![]() |
|
#10
|
||||
|
||||
|
Didn't you post something exactly like this under a different name a week ago, jerry?
|
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Method POST is not allowed on the URL | jwalsh | Computer Software Forum - Windows | 2 | 27-Feb-2004 15:36 |
| Can main host co-exist w/virtual host? | gongkuan | Apache Web Server Forum | 1 | 30-Nov-2003 02:14 |
| Best method to get listed on Google | no1special_1999 | Search Engine Optimization Forum | 4 | 23-Sep-2003 23:34 |
| Main page gone down to PR4 | jrobbio | GIDTopsites™ | 9 | 04-Feb-2003 01:29 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The