Hi i have a simple C question .. :
int main(int argc,char *argv[])
{
char *text;
int textLen,repNum;
text = stream2string(stdin,&textLen);
//....text = argv[0] doesnt work :(
so how can i read from argv[0]? I use netbeans .. and everytime i have to type in stdin.. when i use argv then the programm will execute without my input.
UPDATE :
Everytime , i start the programm(netbeans green button) .. i have to Type an Example String ! I am lazy.. the string is always the same : ABAABAABBBA So ..i will take the first argument instead of stdin . But argv[1] doesn't work either .. here is :
stream2string :
char *stream2string (FILE *fptr, int *n)
{
static char *s;
*n = 0;
ALLOC(s,char,2);
s[*n] = getc(fptr);
while(s[*n]!=EOF && s[*n]!='\0' && s[*n]!='\n') {
REALLOC(s,char,++*n+2);
s[*n] = getc(fptr);
}
s[*n] = '\0';
return(s);
} /* stream2string() */
I think .. setting textLen is also important. Can anybody help ?