![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fopen and open | collins | High Level Programming | 2 | 04-21-2009 02:08 AM |
| Linux fopen() mistery. Help required. | kalbi | UNIX for Advanced & Expert Users | 2 | 03-04-2009 10:21 PM |
| CAN TCPDF USE fopen() or Convert URL To PDF? | athae | Web Programming, Web 2.0 and Mashups | 0 | 07-15-2008 10:25 PM |
| .cc fopen failed - Broken Pipe | kuampang | High Level Programming | 3 | 12-19-2006 11:31 PM |
| Mac OS X - open() and fopen() with French filename | mohit grover | High Level Programming | 1 | 03-09-2005 06:21 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
fopen() - don't know what I'm doing wrong
This code works fine when I use a command line argument for fopen()'s parameter, but when I change it to a filename, the program freezes upon compilation. input.txt is definitely there, so I can't figure it out. Thanks.
Code:
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
int main(int argc, char **argv)
{
int arr[255]={0};
int i=0;
FILE *text=fopen("input.txt", "r");
while ((i = getchar()) != EOF)
arr[i]++;
fclose(text);
for(i='0'; i<'z'; i++)
{
if(isalnum(i) )
fprintf(stdout, "The number of '%c' is %d\n", i, arr[i]);
}
return 0;
}
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|