Question:

A question about files in C programming...Please help!

by  |  earlier

0 LIKES UnLike

i need to write a program in C.

the program should read alphabets from a notepad file. then converts the alphabets in the notepad into digits which is assigned in the program declaration.(a=5, b=8, c=4 etc...)

i've written the reading part of the file but i am having problems to modify the alphabets to digits...Please help!!!!

 Tags:

   Report

3 ANSWERS


  1. Please post your source code.  


  2. /*

    Here is a code snipped with some comments,

    I haven't tried compiling it, but I guess you get the general idea

    */

    #include <stdio.h>

    int convert(char key)

    {

            char charIndex[5]=('A','B','C','D','E');

            int intIndex[5]=(1,2,3,4,5);

            for(int i=0;i<sizeof(charIndex);i++)

                    {

                            if(key==charIndex[i])

                            {

                                    return intIndex[i];

                                    /* Return the integer in the same position as the Character in your conversion array */

                            }

                    }

            return 0;

    //if no match, return zer0

    }

    main()

    {

    char myChars[5]=('A','B','C','D','E'); /* Assume these are the chars from your file in an array */

    int myIntegers[5];

    for(int i=0;i<sizeof(myChars);i++)

            {

                    myIntegers[i]=convert(myChars[i]);

            }

    return 0;

    }


  3. search the web.....u can get the answer

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions