Mail Archives: cygwin/2000/11/07/15:48:16
------=_NextPart_000_008B_01C048EB.2E735A40
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_008C_01C048EB.2E735A40"
------=_NextPart_001_008C_01C048EB.2E735A40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I made a simple code to examplify, a calculation program, but when you =
do: "conta 2 * 4" it doesn't do the multiplication, after making a =
printf call to see what argc[2] contains, it appears 'c'.
Anyone knows what is happening?
Keyser Soze
------=_NextPart_001_008C_01C048EB.2E735A40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>I made a simple code to examplify, a calculation =
program, but=20
when you do: "conta 2 * 4" it doesn't do the multiplication, after =
making a=20
printf call to see what argc[2] contains, it appears 'c'.</FONT></DIV>
<DIV><FONT size=3D2>Anyone knows what is happening?</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Keyser Soze</FONT></DIV></BODY></HTML>
------=_NextPart_001_008C_01C048EB.2E735A40--
------=_NextPart_000_008B_01C048EB.2E735A40
Content-Type: application/octet-stream;
name="conta.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="conta.c"
#include <stdio.h>
main(int argv, char *argc[]){
int num1, num2;
char oper;
if(argv < 4) {
printf("\nWRONG!!!\n%s num1 oper num2", argc[0]);
return(-1);
}
num1 = atoi(argc[1]);
num2 = atoi(argc[3]);
oper = *argc[2];
switch(oper){
case '+': printf("\n %d\n", num1 + num2); break;
case '-': printf("\n %d\n", num1 - num2); break;
case '*': printf("\n %d\n", num1 * num2); break;
case '/': printf("\n %d\n", num1 / num2); break;
default: printf("\n %c nao e operador",oper); break;
}
return 0;
}
------=_NextPart_000_008B_01C048EB.2E735A40
Content-Type: text/plain; charset=us-ascii
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------=_NextPart_000_008B_01C048EB.2E735A40--
- Raw text -