The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-30-2009
lazypeterson lazypeterson is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 13
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0