close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決 
How to Make, Market, and Sell eBooks

Essential and free e-publishing methods to market ebooks at major retailers and personal sites/blogs. Sign up for this online course for just $29.
From our sponsors
c語言 數字跑掉了
Nov 5th 2013, 20:52

有一個input.txt

姓名(32)+(1)空格 電話(10)+(1)空格 地址(32)
John Smith 2022233322 300 E.Oak Taipei 10843
Jane Smith 3435245564 200 E.Oak Taipei 10843
John Jorda 3254656555 100 E.Oak Taipei 10843

可是印出來 ---------------->電話數字不對!!!
姓名 電話 地址
John Smith 8189176 300 E.Oak Taipei 10843
Jane Smith 8189176 200 E.Oak Taipei 10843
John Jorda 8189176 100 E.Oak Taipei 10843

可以幫我看看 為何電話數字會跑掉??
謝謝

我的程式如下
#include<stdio.h>
#include<string.h>

int main (void)
{
typedef struct
{
char name[32];
long int telephone;
char address[32];
} RECORD;
RECORD customer;

FILE *fpInput;
FILE *fpt;
fpInput=fopen("input.txt","r");
char buffer[100]={0};
system("clear");

while(fgets(buffer,sizeof(buffer),fpInput)!=NULL)
{
for(i=0;i<32;i++)
customer.name[i]=buffer[i];
customer.name[31]='\0';
sscanf(buffer,"%ld",&customer.telephone);
for(i=0;i<32;i++)
customer.address[i]=buffer[i+44];
customer.address[31]='\0';
printf("%32s %ld %32s\n",customer.name,customer.telephone,customer.address);
}
fclose(fpInput);
}

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends:

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 omoss 的頭像
    omoss

    中視聶小倩線上看 , 聶小倩線上看第二集 , 聶小倩 中視 , 聶小倩電視劇 , 聶小倩

    omoss 發表在 痞客邦 留言(0) 人氣()