404.817.6900 (215) 686-1776 312-746-6000 877 275 5273 6173434200
and then convert them into the (XXX)XXX-XXXX format.
Here is my code so far:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main() {
FILE *fp;
char str[31], ch;
int i = 0, p1, p2, p3;
fp = fopen("numbers.txt", "r");
while((ch = getc(fp)) != '\n')
{
if(isdigit(ch))
str[i++] = ch;
str[i] = '\0';
i = 0;
sscanf(str, "%3d%3d%4d", &p1, &p2, &p3);
printf("(%3d) %3d-%4d\n", p1, p2, p3);
}
fclose(fp);
return 0;
}
unfortunately it currently doesnt work. when i run it, it prints this:
( 4) 4196261-32767 ( 0) 4196261-32767 ( 4) 4196261-32767 ( 4) 4196261-32767 ( 8) 4196261-32767 ( 1) 4196261-32767 ( 7) 4196261-32767 ( 7) 4196261-32767 ( 6) 4196261-32767 ( 9) 4196261-32767 ( 0) 4196261-32767 ( 0) 4196261-32767 ( 0) 4196261-32767

New Topic/Question
Reply



MultiQuote




|