473,472 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C formating question between Unix and Windows

140 New Member
Hi,

I've continued with my VB->C conversion, and have it working on the Linux box, now I'm going back and getting it to work on the Windows box.

Something strange occurred and I thought I'd try to get you guys input on it.

The code:
Expand|Select|Wrap|Line Numbers
  1. fprintf(datFile, "%10d%10.3e%10.2f%10.3f\n",(intIndex*100+intPart),gdblX,gdblY,gdblZ);
  2.  
Creates on Unix:
Expand|Select|Wrap|Line Numbers
  1. "       101 8.800e-05 180000.00     0.400"
  2.  
But, in windows the same code creates:
Expand|Select|Wrap|Line Numbers
  1. "       1018.800e-005 180000.00     0.400"
  2.  
Which is the same thing except for an extra "0" in the "e" number.

Are there different rules for window formating than unix formating?

Thanks,
Sitko.
Nov 8 '07 #1
6 1503
sitko
140 New Member
My co-workers(engineers) are telling me that 8.800e-05 and 8.800e-005 are the same number, and that it shouldn't be an issue.

But, if anyone has any ideas how to fix this, I'd still be interested in your thoughts.

Note: this file is made up of 10 character wide 'numbers' (padded with spaces) so the fact that the 8.800 runs into the 101 isn't an issue. If you were wondering about that.

Thanks,
Sitko.
Nov 8 '07 #2
sicarie
4,677 Recognized Expert Moderator Specialist
I'd be interested in what compilers you were using on both. Did you use GCC? Or is this possibly a VC/GCC implementation issue.
Nov 9 '07 #3
sitko
140 New Member
I'd be interested in what compilers you were using on both. Did you use GCC? Or is this possibly a VC/GCC implementation issue.
On unix, I used GCC, and on windows, I'm working in Visual C++ (2005).

Its really bizarre how many odd errors are showing up on the windows side which work perfectly fine on the Unix side. Glad there is the ability for platform compiling directives...otherwise, i'd never be able to get this to work on both OSs.

Thanks,
sitko.
Nov 9 '07 #4
sicarie
4,677 Recognized Expert Moderator Specialist
On unix, I used GCC, and on windows, I'm working in Visual C++ (2005).

Its really bizarre how many odd errors are showing up on the windows side which work perfectly fine on the Unix side. Glad there is the ability for platform compiling directives...otherwise, i'd never be able to get this to work on both OSs.

Thanks,
sitko.
Yeah, I'm betting it's just the way libraries are implemented on each. Did you compile GCC with the -wall option? Depending on what they are, you might see some warnings about some of the things that VC++ is complaining about...
Nov 9 '07 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
Creates on Unix:

Code: ( text )
" 101 8.800e-05 180000.00 0.400"

But, in windows the same code creates:

Code: ( text )
" 1018.800e-005 180000.00 0.400"
These don't look the same to me. I mean 101 8 isn't the same as 1018.

That space causes the e-05.

Have you triedn the -pedantic on g++ to disable non standard C++ extensions?/
Nov 9 '07 #6
sitko
140 New Member
These don't look the same to me. I mean 101 8 isn't the same as 1018.

That space causes the e-05.

Have you triedn the -pedantic on g++ to disable non standard C++ extensions?/
As I mentioned above, the program that uses these data files looks for 10 character entries, so even though the 101 is right next to the 8.800..., it still separates the two numbers in its code.

In a further update on my effort, I first got the Unix version to work, then started working on the Windows version, which was WAY harder to get it to work...but eventually I got it working, then for giggles I took the window version back to Unix, to see what additional changes I'd need to make, and it still worked in Unix without having to make (or add ) any changes including additional conditional compiling, which I figured I was going to have to do more so than I had already.

This really impressed me that Unix is so forgiving while windows is so non-forgiving...

Thanks for everyone's help,
Sitko.
Nov 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: inquirydog | last post by:
Hello- I, the inquirydog, would like to solicit suggestions for a new web page I am making: I am creating a simple website that will translate concepts between windows os's, Linux, and the...
6
by: Matthew | last post by:
How would I go about creating a simple "hello world" program that will run in Unix. I am using MS Visual C++.
15
by: spibou | last post by:
My understanding is that when you write a library then the header should be of the form #ifndef macro_corresponding_to_the_library #define macro_corresponding_to_the_library .. .. ...
3
by: svjprakash09 | last post by:
Hi, We have one windows PC and unix PC.We have to connect the unix server from windows client for transfer the files from unix server to windows.Please help me. Regards, Jeyaprakash S
1
by: Shawn Northrop | last post by:
I just read an article on kirupa.com about incorporating mySQL and PHP with flash. I am dynamically loading conent into a flash movie and am not sure how to format. In my php code i have: $y = "";...
2
by: sitko | last post by:
Hi, I'm in the process of converting a VB.net program into a C program so it can run on a unix like machine. I've been moving along at a nice pace, but this conversion has stumped me. I need...
6
by: JML | last post by:
Hi, I have some code which parses a text file and creates objects based on what is in the text file. The code works just fine on Windows, but when I compile it using XCode on OS X the parsing...
34
by: Mark Sullivan | last post by:
What is the difference between the extensions *.hxx and just *.h for header files ? Can they co-exist? Mark
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.