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 3460796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:16:24+00:00 2026-05-18T10:16:24+00:00

Are persistent variables not widely used? I couldn’t find much info about them online

  • 0

Are persistent variables not widely used? I couldn’t find much info about them online or in the index of my C textbook – the Art and Science of C.

Anything you can share about them, especially their scope and example declaration would be helpful. I’m guessing to declare them you use ‘persistent’ as the keyword?

static void foo( void ) {
  persistent unsigned int width = 5;
}

This is the only other helpful reference I could find:
“Persistent variables keep their state when the board is turned off and on, when main is run, and when system reset occurs. Persistent variables will lose their state when code is downloaded as a result of loading or unloading a file.”
http://www.newtonlabs.com/ic/ic_5.html#SEC9

thanks!

  • 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-18T10:16:25+00:00Added an answer on May 18, 2026 at 10:16 am

    The keyword you want is static in local (not global) context.

    The context thing is important:

    #include <stdio.h>
    
    static int foo;
    
    int main(int argc, char **argv){
      //...
    }
    

    Here static means that foo has file scope (i.e. is not extern).

    Whereas in

    char *strtok(char *str, char *sep){
      static char *last;
      //...
    }
    

    last is persistent between calls to strtok.

    All that said, they are rarely used because they are rarely useful, and are totally unacceptable in a multi-threaded context (where they are a race condition waiting to happen).

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

Sidebar

Related Questions

NOTE: This is not the same question as Python: Persistent shell variables in subprocess
Is there a way to clear all persistent variables in MATLAB functions, while keeping
I'm looking for a way to keep the equivalent of persistent global variables in
I'm looking for material on persistent data structures that can be used to implement
Persistent data structures depend on the sharing of structure for efficiency. For an example,
I have a persistent class Author with two fields: int id , String name
I wrote a persistent network service in Perl that runs on Linux. Unfortunately, as
I have persistent object, with a string property that often is over 500 charachters.
In a persistent object, If i change only one field, Is it possible to
Summary: I'm developing a persistent Java web application, and I need to make sure

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.