![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Odd behavior when removing #include statement from source fileAs a modification of my last program, to print squares of a series of integers, I moved the functions to calculate the widths of the two columns to a separate source file. That source file exists strictly to define the calculations;
CPP / C++ / C Code:
Header: CPP / C++ / C Code:
CPP / C++ / C Code:
I found that the left column wasn't being formatted correctly, Quote:
so inserted some cout statements in the relevant function, and discovered quite accidentally that adding CPP / C++ / C Code:
to the FindColumnWidths.cpp source file caused the formatting problem to disappear. Quote:
Why is this? That source file is used only to calculate the widths of the columns and return their int values. All output messages and stream manipulation are done from the main function. The source file doesn't need #include <iostream> to function; so why would adding it there cause the calculations to change? TIA as usual |
|||
|
#2
|
|||
|
|||
Re: Odd behavior when removing #include statement from source fileQuote:
I respectfully suggest that you go back with your finished program and put the #include <iostream> back in and take it out again. If it gives you different results (and #including or not #including the header is the only thing you change), then. 1. Tell us what compiler you are using. 2. Tell us how you are compiling the files. (Make file? Batch file/script? Project in some Integrated Development Environment? What?) Regards, Dave |
|
#3
|
|||
|
|||
Re: Odd behavior when removing #include statement from source fileQuote:
Quote:
I'm using XCode 2 on a Mac. I guess I'll try it in Dev-C++ on my POS PC and see what happens there. |
|
#4
|
|||
|
|||
Re: Odd behavior when removing #include statement from source fileWell, it doesn't seem to exhibit that behavior in Dev-C++. I'm mystified - guess I have to find a specific XCode forum to get answers to the original question.
|
|
#5
|
|||
|
|||
Re: Odd behavior when removing #include statement from source fileHere's a clue, which doesn't tell me anything, but maybe it'll speak to you guys..
I set up the debugger to watch the variables being passed into function findRootWidth. When the line CPP / C++ / C Code:
is enabled in the source file, the variable is passed as I expect. When that line is disabled, the variable always shows up as 2.233392082528404e-308, no matter what the argument is. This is in XCode 2.4.1, GCC 4.0.1, Apple build 5367. Any thoughts? |
|
#6
|
|||
|
|||
Re: Odd behavior when removing #include statement from source fileQuote:
Compile with #include <iostream>. Run from a command line (not from inside XCode IDE). Compile with //#include <iostream>. Run from a command line. Regards, Dave |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 08:44 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 08:10 |
| help with classes | bucho | MS Visual C++ / MFC Forum | 3 | 20-Oct-2004 07:16 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 12:28 |
| [Tutorial] Standard I/O | aaroncohn | C Programming Language | 20 | 27-Feb-2004 22:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The