Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 14th, 2007, 01: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




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 11: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.