Thread: variable modified ''at file scope

  1. #1
    Registered User
    Join Date
    Dec 2020
    Posts
    1

    variable modified ''at file scope

    I have a program where I get the error:
    variable modified 'artikel'at file scope
    char artikel[ARTNAME];

    I think I have to add a #define, but I don't understand exactly which one.
    Please help me ?

    Here is my Code:

    Code:
    #include <stdio.h> #include <string.h> const int ARTNAME = 100; typedef struct artikel{ char artikel[ARTNAME]; int anzahl; } artikel; int main(){ }

  2. #2
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    797
    Yes, "ARTNAME" should be a #define.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,536
    You need to change
    const int ARTNAME = 100;
    to
    #define ARTNAME 100
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 02-21-2012, 04:54 PM
  2. Replies: 8
    Last Post: 02-14-2010, 04:14 PM
  3. Variable scope
    By Axel in forum C Programming
    Replies: 2
    Last Post: 09-19-2005, 08:41 PM
  4. variable in file scope ???
    By howhy in forum C++ Programming
    Replies: 5
    Last Post: 08-30-2005, 04:46 AM
  5. Replies: 29
    Last Post: 12-13-2004, 05:20 PM

Tags for this Thread