0

I keep getting the error in subject, below is the code. Especially in type of constant N; I would like to count 10 100 and 100 to infinity.

What is wrong and how best to fix it?

#include <iostream>
#include <stdio.h>
#define N 100
#define start 1

int main()
{
    system("cls");
    long int a1,a2;
    long int res1,res2;
    long int c1,c2;
    a1=start;
    a2=a1+N;
    res1=(a2+2)/5;
    res2=(a2+4)/6;

    long int i,q,z,g;
    int nums[N];

    for (i=start; i<(start + N); i++) {
        nums["i<start"+1]=10*i+8;
    }
    for (i=1; i<N; i++) {
        for (q=1;q<=res1;q++) {
            c2=(a2+q+2)/(10*q-8);
            c1=(a1+q+2)/(10*q-8)+1;

            for (g=c1;g<c2;g++) {
                z=(10*q+8)*g-(q-2);
                if ((z-start+1)<N)
                    nums[z-start+1]=0;
                else 
                    break;
            }
        }
        for (q=1;q<=res2;q++) {
            c2=(a2+q)/(10*q-6);
            c1=(a1+q)/(10*q-6)+1;
            for (g=c1;g<=c2;g++) {
                z=(10*q-6)*g+q;
                if ((z-start+1)<N)
                    nums["z-start"+1]=0;
                else 
                    break;
            }
        }

    }
    for (i=1;i<N;i++)
        return 0;

}
3
  • 3
    nums["i<start"+1] makes no sense whatsoever. Whatever that's supposed to be, it's wrong. Commented Oct 2, 2016 at 19:51
  • @SamVarshavchik It could be an ingenious stack overflow exploit. Commented Oct 2, 2016 at 19:54
  • @nicomp :) but no. Commented Oct 2, 2016 at 19:58

1 Answer 1

2

Well, the compiler already says what's the problem. nums["i<start"+1] and nums["z-start"+1] leads to that error. You cannot index an element through a string (also called const char*). Simply replace it with nums[i-start+1] (or whatever you meant with <) and nums[z-start+1].

Also your code is not really well written. Don't use short variable names like N or g or c2, it's just confusing (prefer long / logical ones). Commenting your project and learning about compiler errors also never hurts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.