473,385 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help needed in solving C-errors

When i tried to compile this test driver for an actual conversion library
i'm trying to make I got the following messages from gcc.
/*problems reported*/

gcc convertlib.c main.c -ansi -pedantic

main.c:21:22: warning: character constant too long
main.c:22:41: warning: multi-character character constant
main.c: In function `convert':
main.c:22: warning: comparison is always false due to limited range of data type
main.c:22:61: warning: multi-character character constant
main.c:22: warning: comparison is always false due to limited range of data type

What i really want is for the convert() function in main() to behave correctly to
the way i'm passing its parameter.

I'm guessing i screwed up somewhere in the convertlib.h definition or in
the main.c convert() implementation...
Please help !!!


/* main.c */

#include <stdio.h>
#include "convertlib.h"

int main()
{
int result = 0;

result = convert(12, "imperial", "inch", "feet");

printf("\n12 imperial inches = %d feet\n", result);

return 0;
}

int convert(int unit, const char *sys, const char *initial, const char *final)
{
int success = 0;

switch(*sys)
{
case 'imperial':
if (*initial == 'inch' && *final == 'feet')
success = conv_inch2feet(unit);
default:
success = 1;
};

return success;
}
/*convertlib.h*/
#define FOOT 12 /* # of inches in a foot
int conv_inch2feet(int inch);
int convert(int unit, const char *,const char *,const char *);

/*convertlib.c*/
int conv_inch2feet(int inch)
{
feet = inch / FOOT;

return feet;
}
Nov 13 '05 #1
1 1954
In <bf************@ID-168218.news.uni-berlin.de> Bertrand Mollinier Toublet <be***********************@enst-bretagne.fr> writes:
You are obviously not overly at ease with C strings. Remember: there is
no syntactic support for strings in C.


Actually there is, just not very much. String literals certainly qualify
as syntactic support for strings in C.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sims | last post by:
Hi I have a table with something like ID PARENT 0 | -1 1 | -1 2 | 1 3 | 1
7
by: Catherine Jones | last post by:
Hi all we are getting active x component can not create object (Error No. 16) while creating an instance of File System Object in ASP client side script. Could you plz help us in solving this...
25
by: David Bernier | last post by:
I'd like to pass on the command line two filenames. As for example: my_executable filename_1 filename_2 I haven't done any C programming with command line arguments so far. I'm familiar...
5
by: sasiraj | last post by:
#include<stdio.h> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array)) int array = {23,34,12,17,204,99,16}; int main() { int d; for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
13
by: XXXXXX.working.in.my.blood | last post by:
hi all, i need help with linked lists... the problem is this, "reverse the contents of a singly linked list without using a temporary node"... solution with code will be appreciated...
4
by: naknak4 | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
6
by: naknak | last post by:
Introduction This assignment requires you to develop solutions to the given problem using several different approaches (which actually involves using three different STL containers). You will...
5
by: jvdb | last post by:
Hi there, I am quite new on python programming and need some help on solving my problem.. I have to make a (python) program which deletes files from directories. I don't think deleting, etc....
2
by: mia23 | last post by:
Hello, I am a java beginner and I need series help in solving this program; my assignment is due after 2 days and I can't understand this program . This is THE PROGRAM:  The ABC medical clinic...
3
by: NatRoger | last post by:
Hi, We are using DB2 V7 (MVS) in our shop, which dont have the luxury of the 'WITH clause' - CTE support to accomplish recursive queries. Here is my problem - Table1 From-ID To-ID A1 ...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.