how do I get the numbers and the code to line up correctly?
Your logic is a bit off. Check if c is a newline. If it is, print c, and then print a line number. Otherwise, just print c. You might also want to print a line number before your loop so that your first line is numbered.
A couple of other things:
You should have warnings turned on for your compiler. This would have helped you catch your initial problem much easier. For example, if you were using gcc to compile, you would use (at minimum) the -Wall and -Wextra switches, e.g.,
Consult your manual pages for specific details about your system.
The second is more nitpicky, but still good to know. The above program is not exactly conforming C - not to C89, and not to C99. In C89, main may be declared as above, but must have an explicit return statement. Under C99, main must be declared as one of the following:
Additionally, under C89, an explicit return at the end of main is required. In C99, it is not, and if not provided, a return value of zero is implied. Had you turned your compiler warnings on, it may have told you that you did not return a value from main in your 'cat -n' program.
We are running a SQR program on Unix Platform with Oracle RDBMS.
It's an interfacing program to integrate data from foreign sites to
PeopleSoft database, using a flat file input.
After many hours of processing, the program stops with a coredump error (memory fault). With top command we noticed... (1 Reply)
Dear All,
I made a program which do some simple jobs like reading data from other process's shared memory and writing messages to the queues of other process.
what happens is my program works fine and do all the task as expected but then then program ends it give Memory fault(coredump). I... (0 Replies)
Hi All
Can anybody help me?
When ever am trying to run topas system gives me an error Segmentation fault(coredump)
does anybody ahve solution for this? (4 Replies)
Hey guys,
I am new to the Linux world and have a question to post.
When I ssh from a HP-UX machine to a ubuntu machine I get the following error message
Memory fault(coredump)
i.e. ssh 192.168.1.3
I get this message as shown below
Memory fault(coredump)
Can someone please explain... (2 Replies)
Getting memory fault (coredump) and segmentation fault(coredump)
when i tried javac or java -version. what could be the problem?
Regards
Eswar (2 Replies)
I'm getting this error when trying to run a Acucobol program thru UNIX..
Segmentation Fault(coredump)
Precompiler error prevents compilation of xxxxxx.co.
Please help me in this case.. (1 Reply)
Hi,
Actually I am facing one issue while using the getenv() in the C/C++ program.
I want to take the file path from environment variables and if am not defining the environment path, its showing the message like this…!
Memory fault(coredump)
Actually I want to handle the error ,... (6 Replies)
i have few log files that are input to my perl script...
i am executing the script as below
cat RTR*.log | test.pl
and getting the following error
-ksh: 25014: Memory fault(coredump)
cat: write error: Connection reset by peer
can anyone help me on this....
Thanks in... (2 Replies)
Hi Experts,
While running a command, i saw this error below
# ls -lrt
total 74008
-rw-r--r-- 1 rr57104 edcfes 37889134 May 16 12:41 LGTOnw.clnt.7.4.2.0.bff.tar.gz
drwxr-xr-x 2 root system 256 May 18 12:42 lost+found
# gunzip LGTOnw.clnt.7.4.2.0.bff.tar.gz
Memory fault(coredump)
... (2 Replies)
Hi,
In my application we have one job which is used to process the files. But that job is failing with memory fault while processing a file or while shutting down the job. Sometime it generates the coredump and sometimes not. When I analysed the core dump I got below code snippet where it... (3 Replies)
Discussion started by: shilpa_20
3 Replies
LEARN ABOUT CENTOS
tk_main
Tk_Main(3) Tk Library Procedures Tk_Main(3)__________________________________________________________________________________________________________________________________________________NAME
Tk_Main - main program for Tk-based applications
SYNOPSIS
#include <tk.h>
Tk_Main(argc, argv, appInitProc)
ARGUMENTS
int argc (in) Number of elements in argv.
char *argv[] (in) Array of strings containing command-line arguments.
Tcl_AppInitProc *appInitProc (in) Address of an application-specific initialization procedure. The value for this argument is
usually Tcl_AppInit.
_________________________________________________________________DESCRIPTION
Tk_Main acts as the main program for most Tk-based applications. Starting with Tk 4.0 it is not called main anymore because it is part of
the Tk library and having a function main in a library (particularly a shared library) causes problems on many systems. Having main in the
Tk library would also make it hard to use Tk in C++ programs, since C++ programs must have special C++ main functions.
Normally each application contains a small main function that does nothing but invoke Tk_Main. Tk_Main then does all the work of creating
and running a wish-like application.
When it is has finished its own initialization, but before it processes commands, Tk_Main calls the procedure given by the appInitProc
argument. This procedure provides a "hook" for the application to perform its own initialization, such as defining application-specific
commands. The procedure must have an interface that matches the type Tcl_AppInitProc:
typedef int Tcl_AppInitProc(Tcl_Interp *interp);
AppInitProc is almost always a pointer to Tcl_AppInit; for more details on this procedure, see the documentation for Tcl_AppInit.
KEYWORDS
application-specific initialization, command-line arguments, main program
Tk 4.0 Tk_Main(3)