Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7491815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:10:49+00:00 2026-05-29T16:10:49+00:00

I have to write a program for my C programming class that takes a

  • 0

I have to write a program for my C programming class that takes a text file outlining the Letter Frequency, and then use that information to take another text file input that is encrypted and decrypt it using that letter frequency. At first, I didn’t really know how to start… so I decided to start throwing all of my thoughts into a main function and just trying to get it to work from there, but I feel like I’m doing this in such a convoluted manner and now I’m at the point where I just wanted to test to see if used the concept of structures right by outputting an array of structures on screen with all of my information, but I’m getting an error: Line 43 –> Subscripted Value is Neither Array nor Pointer.

I’ve never seen such an error before and I’m not really sure what it means… I was hoping I could show you what I have so far and perhaps someone could explain this error to me and give me some advice on how I should proceed in writing this code (advice and explanations please as it’s detrimental that I learn the material ^_^).

Here is my code:

struct keyFreq
{
    char letter;
    float freq;
};

int main()
{
    FILE *fin;
    char freqname[20];
    char derp;
    char temp[6];
    int spacecounter = 0;
    printf("What is the name of the frequency file? ");
    scanf("%s", freqname);
    fin = fopen(freqname, "r");
    struct keyFreq k[25];
    while(!feof(fin)) {
        fscanf(fin, "%c", &derp);
        int i;
        for(i = 0; i < 26; ++i) {
            if((isalpha(derp)) && k[i].letter == NULL) {
                k[i].letter = derp;
                break;
            }
            if((isadigit(derp)) || derp == '.') {
                int j;
                for(j = 0; j < 7; ++j) {
                    if(temp[j] == -1)
                        temp[j] = derp;
                }
                break;
            }
            if((isspace(derp)) && (k[i].freq == '\0') && (spacecounter >= 2)) {
                double now;
                int k;
                now = atof(temp);
                for(k = 0; k < 7; ++k)
                    temp[k] = -1;
                k[i].freq = now; //Problematic Line <--
                spacecounter = 0;
                break;
            }
            if((isspace(derp)) && spacecounter < 2)
                spacecounter = spacecounter + 1;
            }
        }
        return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:10:50+00:00Added an answer on May 29, 2026 at 4:10 pm
                int k;
                now = atof(temp);
                for(k = 0; k < 7; ++k)
                    temp[k] = -1;
                k[i].freq = now; //Problematic Line <--
    

    k is redeclared in the first line of this code snippet: int k;

    It shadows your initial declaration of k object: struct keyFreq k[25];. To fix this, use two different names in the two variable declarations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write a program for my C programming class that converts IPV4
I have to write a program that read from a file that contains the
I have been assigned wit the task to write a program that takes a
I have an assignment in my C programming class to write a program to
I have to write a program that sniffs network packets (part1-the simple part). And
I wanted to write a program that test if two files are duplicates (have
I have a program for a C class I need to write. The program
Imagine we have a program trying to write to a particular file, but failing.
Recently for a programming class, we were given the assignment to write a program
I am new in java programming. I have write a small web program using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.