Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 14th, 2007, 12:06 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tesh
Default Bug or no to bug learning C using VS.Net to compil

Gurus.

I have written the following code with the help of Ivor Horton's Beginning C :

// Structures, Arrays of Structures.

#include "stdafx.h"
#include "stdio.h"
#define MY_ARRAY 15
#define BASIS 360

    struct swap
    {
        char counterParty[10];
        float notional;
        float intRate;
        int busDays;
        //int basis = 360;
        float flows;
    };

void main()
{

    /*Arrays of Structures*/

    swap myArraySwap[MY_ARRAY];


    int hcount = 0;
    int i = 0;
     //='\0';

// for (hcount = 0; hcount < 5 ; hcount++ )
    do
    {
        char test = NULL;
        printf("\nWould you like to enter Swaps (Y or N)?:");

        test = getchar();

        if (test != 'Y') //|| test !='y')
            break;

        printf("\nEnter CounterParty:");
        scanf("%s", &myArraySwap[hcount].counterParty );
        printf("\nEnter Notional :" );
        scanf("%f", &myArraySwap[hcount].notional );
        printf("\nEnter Interest Rate:" );
        scanf("%f", &myArraySwap[hcount].intRate );
        printf("\nEnter Number of days:" );
        scanf("%d", &myArraySwap[hcount].busDays );
        myArraySwap[hcount].flows = (myArraySwap[hcount].notional * (myArraySwap[hcount].intRate/100.0f) * ((float)myArraySwap[hcount].busDays/360.0f));

        hcount++;
    }
    while (hcount < 5);

    for (i=0 ; i < hcount ; i++)
    {
    printf("\nCounter Party: %s",myArraySwap[hcount].counterParty);
    printf("\nFlows %f", myArraySwap[i].flows);
    printf("\nDone");
    }


}


Problem:

First time around the var test = '' and I can enter a value i.e. Y

here is the dos output:

Would you like to enter Swaps (Y or N)?:Y

Enter CounterParty:Test

Enter Notional :1000

Enter Interest Rate:5.25

Enter Number of days:35

Would you like to enter Swaps (Y or N)?:

second time around the at the point of test = getchar(); test is set to '0 ' automatically and I am not able to enter Y or N.

when the app reaches:test = getchar(); it automatically sets the var from Y 89 to : 0 ''

is this compiler related i have vs.net 2003 ?

i have also tried scanf and get the same :(

thank you.

tesh
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET bug: Error reflecting complex object with Nul peterwood .NET Web Services 0 February 7th, 2008 10:35 AM
RegEx Bug?? dparsons ASP.NET 1.0 and 1.1 Professional 0 October 9th, 2006 09:08 AM
VB.NET - oledbcommand.parameters BUG AleBernardi BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 October 9th, 2004 05:56 AM
Bug happens guoqi BOOK: ASP.NET Website Programming Problem-Design-Solution 0 October 13th, 2003 01:35 PM



All times are GMT -4. The time now is 04:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.