help me!!

Discussion in 'C' started by bengt23648, Mar 20, 2007.

  1. bengt23648

    bengt23648 New Member

    Joined:
    Mar 20, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    i have a code here.. it has one error.. and i don't know what to do.. CAN YOU PLEASE HELP ME.. CAN YOU PLEASE REPAIR MY CODE... PLEAAAASSSEEE!!!

    here's my code.. (it has only one error..)

    <----------------------------->
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <string.h>
    
    void initval();
    
    int chars[255];
    
    int main()
    {
    	FILE *file_r;
    	int ferr = 0, i;
    	char filename[50];
    	while (ferr == 0)
    	{
    		system("cls");
    		printf("Enter file name: ");
    		gets(filename);
    		file_r = fopen(filename, "r");
    		if (file_r == 0)
    		{
    			printf("Error! File does not exist!");
    			getch();
    		}
    		else
    		{
    			ferr = 1;
    		}
    	}
    	char *r;
    	char c, ctr = 0;
    
    	while ((c = getc(file_r)) != EOF)
    	{
    		ctr++;
    	}
    	
    	fclose(file_r);
    	file_r = fopen(filename, "r");
    	
    	char string[ctr];
    	
    	i = -1;
    	while ((c = getc(file_r)) != EOF)
    	{
    		i++;
    		string[i] = c;
    	}
    	
    	printf("\n%s", string);
    
    	printf("\n\n%s\n\n", strrev(string));
    
    	//tig-ihap
    
    	for (i = 0; i < strlen(string); i++)
    	{
    		chars[string[i]]++;
    	}
    	
    	for (i = 0; i < 256; i++)
    	{
    		if (chars[i] != 0)
    		{
    			printf("%c = %d\n", i, chars[i]);
    		}
    	}
    	
    	getch();
    	
    	fclose(file_r);
    	return 0;
    }
    
    void initval()
    {
    	int i;
    	for (i = 0; i < 256; i++)
    	{
    		chars[i] = 0;
    	}
    }
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    And are we to guess what the error is? Perhaps we should spend lots of time searching for it, so you won't have to be bothered helping us help you.

    Also, please read the "Before you make a query" thread. Note its rationale for posters using meaningful subject lines. "Help me" does not qualify. Whining isn't very adult-like, either.
     
  3. savitri

    savitri New Member

    Joined:
    Mar 23, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    pls anybody help by giving the code for the below c program. its very urgent....
    --
    below is the assignment. findout the person who is good at c language...actually its eassy thing, i don't no much programming. so i need help....if i do it right,they will consider me..i have to send this assignment tomorrow morning.

    This is the assignment

    Write a program, using c language,
    1. Reads a Holiday configuration file
    2. Get the current date
    3. Open output file
    4. if (TODAY is weekday AND not Holiday) print "Next business day is <<NEXTWEEKDAY>>" in output file
    Where NEXTWEEKDAY is a variable and NEXTWEEKDAY should not be Holiday

    Example: TODAY is APRIL 5th and THURSDAY
    Next Business day is "MONDAY" because April 6th is Good Friday and is a Holiday

    Example of Holiday list :
    Jan 1, Jan 15, Feb 19, April 6, May 28, July 4, etc

    It can be any day as long as specified in Holiday file .
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If you are looking some one to hire you can try the job section of this forum or the marketplace of cfanatic.com
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice