473,800 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ 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 1520
sitko
140 New Member
My co-workers(enginee rs) 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...ot herwise, 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...ot herwise, 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
3016
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 Java language with all of its related technologies. The website is at http://members.dslextreme.com/users/inquirydog, and is a mock-version of the Rosetta stone, which indicates concepts from each "platform"
6
4133
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
1766
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 .. .. ...definitions... .. #endif This prevents the objects in the library to be
3
2088
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
2553
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 = ""; foreach($result as $x){ $y = $y . $x . " "; } print "myVar = $y"; In short $result is a query and $y is the value i will be passing along to flash. the statement $y = $y . $x . " "; puts a space between each name that is passed along. I am...
2
1751
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 a function to take two arguments:(a double number which may or may not be an integer, and an integer which will be the number of digits to store after the decimal place) it needs to turn this into a string which is always 10 characters long. if the...
6
6779
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 goes all wrong. Is there some known differences with file handling on OS X? My code is quite long, but one of the defect parts looks like this (sorry about the indentation - I'm new to posting code on a newsgroup):
34
19916
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
8369
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 object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++ doesn't have such functionality, say in its STL. This absence of a thread/object relationship in...
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10250
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.