TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Paul Edwards
from: Kieran Haughey
date: 1996-01-10 00:35:00
subject: ..argv

On 07 Jan 96 13:53, Paul Edwards wrote to Kieran Haughey:

Hi Paul,

KH>> I was wondering why this occurs.. in my code I use the following

KH>> char chk_cmdline(int argc,char **argv,int *startpos)
KH>> [snipped] 
KH>>     *(argv++);

KH>> I was accessing varibles of the seperate argv's by using *(*argv).. and 
KH>> found that if I did a plain argv++ it would only goto the next character 
KH>> in argv, not the next array element...

PE> Someone's telling porkies!  Show the code (small), and insert a 
PE> printf("%p", argv); before and after the increment, and then
PE> apologize for telling porkies.  Fair enough?  BFN.  Paul.

Well I haven't checked it before or after the increment.. but it is working for me.. 

ok, here's the entire function :)
I threw it in getopts because it was relitivly the same thing :)



/* following by Kieran Haughey */
/* returns 0 for FALSE and 1 for TRUE */
/* also returns where the normal text starts from */
char chk_cmdline(int argc,char **argv)
{
    int x,count=0,count2=0;

    argc--;
    argv++;

    for(x=1;x<=argc;x++)
    {
        if((*(*argv) == '-') || (*(*argv) == '/'))
            count++;
        if(strstr(*(argv),"."))
        count2++;
        *(argv++); /* if I replace this with argv++ it doesn't work.. */
                   /* btw, this it the line it gives the warning on */
    }
    if(count == argc && count2==0)
        return 0;
    if(count != argc && count2>0)
        return 1;
    return 0;
}


I should also mention that this function WORKS :).. I use it in Dupey :)..
and Dupey wouldn't accept command line config definition :)..

Now where am I supposed to have been telling porkies?.. 
ÿ
Cheers,
Kieran

3:711/413.17{at}fidonet
@EOT:

--- MsgedSQ 3.30
* Origin: -=> The Last Stand Against Sanity <=- (3:711/413.17)
SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 420 423 430 510 808 809
SEEN-BY: 711/932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 711/413 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.