LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2004, 03:28 AM   #1
']['HeBroken
Member
 
Registered: Oct 2004
Posts: 35

Rep: Reputation: 15
Need Quick Help With C Problem!!!


ok i have class in about 4 hours and im stessing the hell out cause this program is so easy to write but yet so hard for me. im only one week into programming and i have variables, constants, main fuction, if's elses and what not coming out of my ear. well here is the problem im using Visual Studio 2005 beta version and i wrote the program in it and i have a few errors ill show you what i mean....

Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void)
{
	float fPrice, fResult;
	char cCode, cOper;
	
		printf("\n Please Enter The Price Of The Item");
			scanf ("%f", &fPrice);
			fflush(stdin);


		printf("\n Please Enter the Discount Code");
			scanf ("%c", &cCode);
			fflush(stdin);

	switch( tolower (cCode) )
	{
	case 'h':
	case 'H':
	
	fResult = .5 * fPrice;
	cOper = '*';
	break;
	
	case 'f':
	
	fResult = .4 * fPrice;
	cOper = '*';
	break;

	case 't':
	
	fResult = .33 * fPrice;
	cOper = '*';
	break;

	case 'q':
	case 'Q':

	fResult = .25 * fPrice;
	cOper = '*';
	break;

	case 'z':

	if ( cCode == 'z')
	{
	fResult = fPrice;
	}
	else
{
	printf("\n You Gotta Pay Full Price Biatch");
	return 1;
}
	printf("%f %f %c", fResult, fPrice, cCode);

	return 0;
	}

then i get the errors messages

Code:
------ Build started: Project: f, Configuration: Debug Win32 ------
Compiling...
fff.c
c:\Documents and Settings\Administrator\Desktop\f\fff.c(11) : warning C4996: 'scanf' was declared deprecated
        c:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(276) : see declaration of 'scanf'
c:\Documents and Settings\Administrator\Desktop\f\fff.c(16) : warning C4996: 'scanf' was declared deprecated
        c:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(276) : see declaration of 'scanf'
c:\Documents and Settings\Administrator\Desktop\f\fff.c(24) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\Documents and Settings\Administrator\Desktop\f\fff.c(30) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\Documents and Settings\Administrator\Desktop\f\fff.c(36) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\Documents and Settings\Administrator\Desktop\f\fff.c(43) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
c:\Documents and Settings\Administrator\Desktop\f\fff.c(63) : fatal error C1075: end of file found before the left brace '{' at 'c:\Documents and Settings\Administrator\Desktop\f\fff.c(6)' was matched
Build log was saved at "file://c:\Documents and Settings\Administrator\Desktop\f\Debug\BuildLog.htm"
f - 1 error(s), 6 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


now i need some serious help im so mind screwed i kant think... please help me....... thanx in advance...
 
Old 10-20-2004, 04:00 AM   #2
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
- You can declare fPrice and fResult as double to prevent possible data loss
- You didn't close the brace of `switch' as i see.
and I would ignore the message about scanf..

Also, try not to use a windows box with the administrator account. It's almost same with using root account in GNU/Linux.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help quick login problem greenthing SUSE / openSUSE 1 03-30-2005 02:10 PM
quick config problem ach1lles Linux - Newbie 1 02-19-2005 11:29 PM
Quick Launch Problem don_dimo Linux - Newbie 1 06-03-2004 04:54 AM
Very quick fdisk problem BarryM45 Linux - Newbie 1 01-27-2004 09:38 AM
quick problem Cop Linux - Newbie 4 10-26-2003 01:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration