[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
[an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]![]() |
![]() |
![]() |
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
![]() |
![]() |
![]() |
#include <stdio.h> #include <stdlib.h> int main() { int weight; int age; char weightchar[5]; char agechar[3]; printf("How much do you weigh?:\n"); gets(weightchar); weight=atoi(weightchar); printf("How old are you?:\n"); gets(agechar); age=atoi(agechar); printf("So you are %i years old and weigh %i, Man you are OLD AND FAT!\n",age ,weight); } Det her er fra en tutorial jeg forstårbare ikke hvilken nytte atoi så gør i det her eksempel... er det hvis brugeren fx skriver "about 65 kilos" eller hva? "Jesper" <sslug@sslug> wrote in message news:sslug@sslug > Ok hvorfor 0 ved abc123??? > > Og vil det sige hvis jeg skriver et kommatal laver atoi det om til nærmeste > hele tal?? > "Henrik Witt-Hansen" <sslug@sslug> wrote in message > news:sslug@sslug > > Hi. > > > > > funktionen atoi hvad gør den egentligt?? Sikrer at en > > > given input ER en integer eller?? > > > > Konverterer den del af en streng som er et tal, til et tal.. > > ehem. altså.... > > > > > > > > #include <stdio.h> > > #include <stdlib.h> > > #include <unistd.h> > > int main() > > { > > char string1[]="123abc"; > > char string2[]="abc123"; > > char string3[]="abc"; > > char string4[]="123"; > > printf("%s: %d\n",string1,atoi(string1)); > > printf("%s: %d\n",string2,atoi(string2)); > > printf("%s: %d\n",string3,atoi(string3)); > > printf("%s: %d\n",string4,atoi(string4)); > > return 0; > > } > > > > > > output: > > > > 123abc: 123 > > abc123; 0 > > abc: 0 > > 123: 123 > > > > > > > > bean > > > >
![]() |
![]() |
![]() |
||||||||||||
|
||||||||||||||
![]() | ||||||||||||||
|
||||||||||||||
![]() |
![]() |
![]() |