Sponsored Content
Top Forums Programming C program to display a busy symbol while processing Post 302634471 by Corona688 on Thursday 3rd of May 2012 11:37:15 AM
Old 05-03-2012
Here's an extremely simple way:

Code:
#include <stdio.h>
#include <signal.h>

void showspin(void)     // Shows a different charcter every time its called
{
        static char *spin="-/|\\", pos=0;
        if(!spin[++pos]) pos=0; // If we hit the NULL terminator, skip to beginning of string
        // We have to use stderr, so it doesn't buffer, since we're not printing a newline
        fprintf(stderr,"%c\r",spin[pos]); // Show character at position 'pos' in string
}

void dospin(int sig)    // Starts showing spinner repeatedly
{
        showspin();
        signal(SIGALRM, dospin); // Register this function to be called on SIGALRM
        alarm(1); // Cause SIGALRM to happen 1 second later
}

void nospin()           // Cancels the spinner
{
        alarm(0);
        fprintf(stderr," \r"); // Erase the spinner
}

int main(void)
{
        int n;
        dospin(SIGALRM);
        for(n=1; n<(1000*1000*2000); n++);
        nospin();
}

This User Gave Thanks to Corona688 For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display a Graphic from a Unix program on a Pc – how?

An interesting puzzle. I run character based compiled C-Programs in a Unix environment on PCs in a Window. I want to be able to call up and display in a separate window a picture of a product called by a Unix shell script from within my Unix program. Ideally I would like to have a script that... (4 Replies)
Discussion started by: Barry Staples
4 Replies

2. UNIX for Dummies Questions & Answers

Parallel processing using AWK program

Hi All, could any expert tell me about writing a parallel processing program using AWK program is possible or not? Any example would be much appreciated... With Regards / Mysore Ganapati :confused: (5 Replies)
Discussion started by: ganapati
5 Replies

3. Linux

Reading ELF file Symbol table of C++ program

Folks, I have some program(Test.cpp) as follows, #include<iostream> class Abc { private: int _theVar; public : int printVar(); }; int Abc :: printVar() { _theVar=10; } main() { Abc _t; (0 Replies)
Discussion started by: vinod_chitrali
0 Replies

4. Programming

Reading ELF file Symbol table of C++ program

Folks, I have some program(Test.cpp) as follows, #include<iostream> class Abc { private: int _theVar; public : int printVar(); }; int Abc :: printVar() { _theVar=10; } main() { Abc _t; (2 Replies)
Discussion started by: vinod_chitrali
2 Replies

5. UNIX for Advanced & Expert Users

Filesystem mystery: disks are not busy on one machine, very busy on a similar box

Hi, We have a filesystem mystery on our hands. Given: 2 machines, A and Aa. Machine Aa is the problem machine. Machine A is running Ubuntu, kernel 2.6.22.9 #1 SMP Wed Feb 20 08:46:16 CST 2008 x86_64 GNU/Linux. Machine Aa is running RHEL5.3, kernel 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38... (2 Replies)
Discussion started by: mschwage
2 Replies

6. Programming

Symbol table of a C program

Hi, is there any command to see symbol table info. will it show where its allocating memory for varibales golbals & locals and code.(i mean the segments). i read there is a section called read only data segment and this is where initialized data such as strings stores. i have wriiten the... (7 Replies)
Discussion started by: MrUser
7 Replies

7. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

8. Programming

To display unique lines in a Program

I am new to C programming. I have been trying to display unique lines in a file from past two days. The problem is here, I have a file whose contents are, ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net ras.beamtele.net... (1 Reply)
Discussion started by: Teju88
1 Replies

9. Shell Programming and Scripting

Output Display in a perl program

Hi All, I have created a sample perl program in one of the unix environment as below #!/usr/bin/perl print "Content-type: text/html\n\n"; print "<H1>Hello World</H1>"; When I execute it in unix, I get the below Content-type: text/html <H1>Hello World</H1> However, when I... (1 Reply)
Discussion started by: mr_manii
1 Replies
ANM(1)							      General Commands Manual							    ANM(1)

NAME
anm - print name list SYNOPSIS
anm [-gnoprus] file ... OPTIONS
-g Global symbols only -n Sort numerically -o Prepend the filename to each line -p No sorting--use symbol table order -r Sort in reverse order -u List undefined symbols only -s Sort in section order EXAMPLES
anm -gn test.o # Print global symbols in numerical order DESCRIPTION
Anm prints the name list (symbol table) of each ACK format object file in the argument list. If no file name is given, a.out is used. Each symbol name is preceded by its value, a section indicator and a type indicator. The section indicators are: U Undefined symbol A Absolute symbol - Other symbol The type indicators are: F Filename M Module name S Section name E External (global) symbol - Local symbol The output is sorted alphabetically, unless otherwise specified. Notice that anm can only be used on ACK format object files (that is: .o and .out files). If you want to get the name list of an executable program use nm instead. SEE ALSO
asize(1), nm(1), ar(1), size(1). ANM(1)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy