1. Ok...finally got everything working

Ok, what is %lf, %c, and %ld?

2. ** REGISTER to REMOVE This Ad On The Site!! **
3. i have not done c in ages but htey just look like the names of variables to me.

how about showing us the code and we can tell ya.

4. Hehe was hoping you would be here

Actually I found out what they were (after extensive researching cough googling)

#ld = LONG Digit (or double.... probably digit)
#lf = LONG float (the L just tells you LONG..... you can use H and that would mean SHORT)
#c = character....

Actually, I&#39;m making a basic C calculator. I&#39;m almost done with it, but I do have some errors.... here&#39;s what I have now (by the way it&#39;s in spanish.... so you might not understand it much, but you would get the point)

Code:
```void main&#40;&#41;
{
&nbsp; double primero;
&nbsp; double segundo;
&nbsp; int cont;
&nbsp; double respuesta;

&nbsp; printf&#40;&#34;La mera calcu de Leksi&#092;n&#092;n&#34;&#41;;

&nbsp; printf&#40;&#34;Instrucciones&#58;&#092;n&#092;n&#34;&#41;;
&nbsp; printf&#40;&#34;Para sumar, utilice la forma x+y&#092;n&#34;&#41;;
&nbsp; printf&#40;&#34;Para restar, utilice la forma x-y&#092;n&#34;&#41;;
&nbsp; printf&#40;&#34;Para multiplicar, utilice la forma x*y&#092;n&#34;&#41;;
&nbsp; printf&#40;&#34;Para dividir, utilice la forma x/y&#092;n&#34;&#41;;
&nbsp; printf&#40;&#34;Para elevar, utilice la forma x^y&#092;n&#092;n&#34;&#41;;
&nbsp;
&nbsp; printf&#40;&#34;Por favor ingrese la operacion a realizar&#092;n&#34;&#41;;
&nbsp; scanf&#40;&#34;%lf %c %lf&#34;, &primero, &operador, &segundo&#41;;

&nbsp; {
&nbsp; &nbsp; &nbsp;case &#39;+&#39;&#58;
printf&#40;&#34;Su respuesta es&#58; &#34;&#41;;
&nbsp; &nbsp; &nbsp;	printf&#40;&#34;%lf&#34;, primero + segundo&#41;;
&nbsp; &nbsp; &nbsp;	break;

&nbsp; &nbsp; &nbsp;case &#39;-&#39;&#58;
printf&#40;&#34;Su respuesta es&#58; &#34;&#41;;
&nbsp; &nbsp; &nbsp;	printf&#40;&#34;%lf&#34;, primero - segundo&#41;;
&nbsp; &nbsp; &nbsp;	break;

&nbsp; &nbsp; &nbsp;case &#39;*&#39;&#58;
printf&#40;&#34;Su respuesta es&#58; &#34;&#41;;
&nbsp; &nbsp; &nbsp;	printf&#40;&#34;%lf&#34;, primero * segundo&#41;;
&nbsp; &nbsp; &nbsp;	break;

&nbsp; &nbsp; &nbsp;case &#39;/&#39;&#58;
printf&#40;&#34;Su respuesta es&#58; &#34;&#41;;
&nbsp; &nbsp; &nbsp;	if&#40;segundo == 0&#41;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf&#40;&#34;&#092;n&#092;n&#092;aSu denominador no puede ser CERO&#092;n&#34;&#41;;
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf&#40;&#34;%lf&#34;, primero / segundo&#41;;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;

&nbsp; &nbsp; &nbsp;case &#39;^&#39;&#58;
printf&#40;&#34;Su respuesta es&#58; &#34;&#41;;
printf&#40;&#34;%lf&#34;, pow &#40;primero,segundo&#41;&#41;;
break;
&nbsp;
&nbsp; &nbsp; &nbsp;default&#58;
&nbsp; &nbsp; &nbsp;	printf&#40;&#34;&#092;n&#092;aSu operacion no es correcta&#34;&#41;;
&nbsp; }
}```
Here&#39;s where I&#39;m stuck at. The calculator works perfectly. For example, if you try "a+1" it gives you the "Incorrect operation" error. However, if the second term is something else (such as 1+a), it would take the second as 0 and give you 1 as the answer. Any ideas? Thanks

5. Ok, yea I just tried everything with something else as the second number (1+a, 1-a, 1*a, 1/a, 1^a) and every time the a is taken as a 0 (zero).

Could this be because of the default?

6. Formatted output: printf description
The format string given to the `printf&#39; function may contain both ordinary characters (which are simply printed out) and conversion characters (beginning with a percent symbol, %, these define how the value of an internal variable is to be converted into a character string for output).

Here is the syntax of a conversion specification:

&nbsp; %{flags: - + space 0 #}{minimum field width}{.}{precision}{length modifier}{conversion character}

Flags: `-&#39; means left-justify (default is right-justify), `+&#39; means that a sign will always be used, ` &#39; prefix a space, `0&#39; pad to the field width with zeroes, &#39;#&#39; specifies an alternate form (for details, see the manual&#33. Flags can be concatenated in any order, or left off altogether.
Minimum field width: the output field will be at least this wide, and wider if necessary.
&#39;.&#39; separates the field width from the precision.
Precision: its meaning depends on the type of object being printed:
Character: the maximum number of characters to be printed.
Integer: the minimum number of digits to be printed.
Floating point: the number of digits after the decimal point.
Exponential format: the number of significant digits.
Length modifer: `h&#39; means short, or unsigned short; `l&#39; means long or unsigned long; `L&#39; means long double.
Conversion character: a single character specifying the type of object being printed, and the manner in which it will be printed, according to the following table:
Character Type&nbsp; &nbsp; Result

&nbsp; d,i&nbsp; &nbsp; int&nbsp; &nbsp; signed decimal integer
&nbsp; &nbsp; o&nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; unsigned octal (no leading zero)
&nbsp; x, X&nbsp; &nbsp; int&nbsp; &nbsp; unsigned hex (no leading 0x or 0X)
&nbsp; &nbsp; u&nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; unsigned decimal integer
&nbsp; &nbsp; c&nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; single character
&nbsp; &nbsp; s&nbsp; &nbsp; &nbsp; char *&nbsp; characters from a string
&nbsp; &nbsp; f&nbsp; &nbsp; &nbsp; double&nbsp; floating point [-]dddd.pppp
&nbsp; e, E&nbsp; &nbsp; double&nbsp; exponential [-]dddd.pppp e[=/-]xx
&nbsp; g, G&nbsp; &nbsp; double&nbsp; floating is exponent less than -4, or >= precision
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else exponential
&nbsp; &nbsp; p&nbsp; &nbsp; &nbsp; void *&nbsp; pointer
&nbsp; &nbsp; n&nbsp; &nbsp; &nbsp; int *&nbsp; the number of characters written so far by printf
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is stored into the argument (i.e., not printed)
&nbsp; &nbsp; %&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print %
Got that from around

7. Great - oh well.

Now I have to do a project. Either a text editor (such as notepad) or a game (Galaga). If you have any ideas on how to do this, please let me know. If you find any programs around, please let me know so I can get ideas from it. I&#39;m lost and I have to send in a part of the program tonight. So I&#39;m in a hurry

Thanks

8. bump

9. Originally posted by shn@23 January 2004 - 20:48
http://www.bluemug.com/research/text.pdf
Cool, thanks for that. I&#39;ll see what I can do

10. Bump

Any help on the game? The Galaga-type of game looks easier, although I have no idea how to make a cycle for the ship to move using gotoxy(x,y)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•