![]() |
|
#1
|
|||
|
|||
C programming troubleI have a little experience in Java programming, but I am completely new to C. So I am a little rusty on my coding.
I'm having trouble with this program I'm trying to write: Some of the errors I have when I try to compile are: Parse error, expecting ''," or 'SEP' CPP / C++ / C Code:
Also: Parse error, expecting ',' or 'SEP' CPP / C++ / C Code:
Here is my entire program: CPP / C++ / C Code:
Last edited by JdS : 13-Sep-2004 at 06:09.
Reason: Please insert your example C/C++ codes between [c] and [/c] tags
|
|
#2
|
||||
|
||||
|
I just finished a C programming course, but I feel I can address your errors at least. ;-)
CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
__________________
Common Sense v2.0-Striving to make the world a little bit smarter. |
|
#3
|
||||
|
||||
|
You can do this
CPP / C++ / C Code:
but the line CPP / C++ / C Code:
This line also needs to be fixed CPP / C++ / C Code:
I'm also curious as to what this line is supposed to do CPP / C++ / C Code:
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#4
|
|||
|
|||
|
I'm also curious as to what this line is supposed to do
CPP / C++ / C Code:
Heh, that segment of code was actually given to us from our professor as to generate the Julian date i.e. number of elapsed days since January 1, 4713 B.C. This function allows me to calculate Jan 1st for any year given. Unfortunately his code has some porblems as I get some "bad type" errors from his code because of the use of long's and int's. |
|
#5
|
||||
|
||||
|
You know what I've done a little research and I believe the mystery line is actually type casting to an int. I could be wrong though. What other errors are you getting?
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#6
|
|||
|
|||
|
Quote:
bad types for * multiply Code:
args of different type Code:
and wrong type for add Code:
|
|
#7
|
||||
|
||||
|
Quote:
Not true. In C, you cannot define i in the for statement. crystalattice was correct. C++ allows it, but not C. And an iterator is optional. As long as the value i or days is modified in the loop the program works fine. Quote:
Quote:
It's obviously meant to confuse even the most learned programmers ;-) Let's add whitespace and parens to make it understandable: CPP / C++ / C Code:
First thing I see is: CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
Oh, and one more thing... The proper format for main is CPP / C++ / C Code:
Quote:
1) no whitespace -- makes it understandable but won't affect the outcome 2) different types which is fine with C Please post the exact errors with the lines that cause them. And let us know what compiler and OS you are using. __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#8
|
|||
|
|||
|
Quote:
Well I decided to try compiling the program on the unix machines at my school and the program compiled with out any errors... When the program executes I get the prompt to "Enter Calendar Year", then when I type in an year like 2004 and hit return, a bunch of blank lines go by and it stops withe curser blink, but I cannot type anything else. I'm assuming I have an error with my scanf() line: CPP / C++ / C Code:
here is the rest of the program: CPP / C++ / C Code:
Last edited by JdS : 13-Sep-2004 at 06:10.
Reason: Please insert your example C/C++ codes between [c] and [/c] tags
|
|
#9
|
||||
|
||||
|
Your problem is in this section of code:
Code:
Then try printing out your variables at key points to see what values you are generating -- this will help you pinpoint what values are not being set properly. Also, for this code: CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
Just a thought... __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Tutorial] GUI programming with FLTK | dsmith | FLTK Forum | 10 | 03-Oct-2005 15:41 |
| GUI programming | crystalattice | CPP / C++ Forum | 5 | 14-Sep-2004 12:17 |
| OZ programming language | runner | MySQL / PHP Forum | 0 | 25-Aug-2004 02:49 |
| Having trouble trying to format C: | Nickster64 | Computer Software Forum - Windows | 2 | 27-Jul-2004 07:31 |
| Need some exercises in C++, plus info on GUI programming. | BlockAndBash | CPP / C++ Forum | 4 | 18-May-2004 20:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The