Working by sheer coincidence. Going beyond the end of the array means you can't predict what data you'll find there. To avoid out of bounds errors, stay in bounds.
sometimes for this code i get a segmentation fault for codes llike this
:
int main{
int * a= 0;
int b;
a = (int*)malloc(sizeof(int));
///some code using these variable but no freeing of a
if(a){
free(a);
a = 0;
}
return... (3 Replies)
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
Hi,
on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error :
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Segmentation fault
What does it mean ? And the solution ?
Many thanks. (0 Replies)
If I do this.
Assume
struct life
{
char *nolife;
}
struct life **life;
// malloc initialization & everything
if(life->nolife == 0)
Would I get error at life->nolife if it is equal to 0.
wrong accession? (3 Replies)
I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int outputToImport(const char*... (1 Reply)
i have this code
int already_there(char *client_names, char *username) {
int i;
for(i = 0; i<NUM; i++) {
printf("HERE\n");
if (strcmp(client_names, username)==0) return(1);
}
return(0);
}
and i get a segmentation fault, whats wrong here? (7 Replies)
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
Hi Guys,
I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error:
"Segmentation fault"
Can someone please help me resolve this?
Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies
LEARN ABOUT PLAN9
arg
ARG(2) System Calls Manual ARG(2)NAME
ARGBEGIN, ARGEND, ARGC, ARGF, arginit, argopt - process option letters from argv
SYNOPSIS
#include <u.h>
#include <libc.h>
ARGBEGIN {
char *ARGF();
Rune ARGC();
} ARGEND
extern char *argv0;
/* Alef only */
Arg *arginit(int argc, byte **argv);
Rune argopt(Arg *arg);
byte *argf(Arg *arg);
DESCRIPTION
These macros assume the names argc and argv are in scope; see exec(2). ARGBEGIN and ARGEND surround code for processing program options.
The code should be the cases of a C switch on option characters; it is executed once for each option character. Options end after an argu-
ment --, before an argument -, or before an argument that doesn't begin with -.
ARGC() returns the current option character.
ARGF() returns the current option argument: a pointer to the rest of the option string if not empty, or the next argument in argv if any,
or 0. ARGF must be called just once for each option that takes an argument.
After ARGBEGIN, argv0 is a copy of argv[0] (conventionally the name of the program).
After ARGEND, argv points at a zero-terminated list of the remaining argc arguments.
Alef
The Alef argument processing routines are unrelated. Instead, an aggr called Arg is initialized by a call to arginit. Successive calls to
argopt return successive option characters, or zero at the end of the options. After a call to argopt, argf will return any argument
string associated with the option.
EXAMPLES
This C program can take option b and option f, which requires an argument.
#include <u.h>
#include <libc.h>
void
main(int argc, char *argv[])
{
char *f;
print("%s", argv[0]);
ARGBEGIN {
case 'b':
print(" -b");
break;
case 'f':
print(" -f(%s)", (f=ARGF())? f: "no arg");
break;
default:
print(" badflag('%c')", ARGC());
} ARGEND
print(" %d args:", argc);
while(*argv)
print(" '%s'", *argv++);
print("
");
exits(0);
}
Here is the output for the run prog -bffile1 -r -f file2 arg1 arg2
prog -b -f(file1) badflag('r') -f(file2) 2 args: 'arg1' 'arg2'
This Alef program accepts options b and, with an attached file name, f.
#include <alef.h>
void
main(int argc, byte **argv)
{
int a, ac, bflag;
byte *file;
Arg *arg;
arg = arginit(argc, argv);
while(ac = argopt(arg)) switch(ac){
case 'b':
bflag = 1;
break;
case 'f':
file = argf(arg);
break;
}
for(a=0; a<arg->ac; a++)
print("argument %s
", arg->av[a]);
}
SOURCE
/sys/include/libc.h
ARG(2)