Unknown error in compilation

This is a discussion on Unknown error in compilation within the C Programming forums, part of the General Programming Boards category; Hi i get a "subscripted value is neither array nor pointer" when i compile my source. the error is pointing ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    31

    Unknown error in compilation

    Hi i get a

    "subscripted value is neither array nor pointer"

    when i compile my source.

    the error is pointing this line

    Code:
    if(strncmp(">", argc[i], 1) == 0)
    argc is the argument taken from the program parameters

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Perhaps you wanted argv? You may also say:

    Code:
    if(argv[i][0] == '>') // blah blah

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    31
    It looks like the program does not pick up the > character. It will assumedly pipe it out to what ever is on the other end.

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    If you put it in quotes it will work. This could be awkward for your application however.

  5. #5
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    The |, < and > characters are stripped by the OS and not passed to the program. Unless you surround them with "s
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  6. #6
    Registered User wintellect's Avatar
    Join Date
    Mar 2006
    Posts
    24
    you could also lookup the ascii value for the character '>' and use that instead in the comparison

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Won't work, the ">" won't get sent to the program in the first place.

    Maybe you could try use a different symbol...
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Code:
    if(strncmp(">", argc[i], 1) == 0)
    Are you sure you don't want this?
    Code:
    if(strncmp(">", argv[i], 1) == 0)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 02:29 PM
  2. Simple C++ Compilation Question
    By mercury529 in forum C++ Programming
    Replies: 14
    Last Post: 07-30-2006, 10:40 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  4. MS VC++ Crash on compilation
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 08-23-2003, 08:06 PM
  5. UNICODE and GET_STATE
    By Registered in forum C++ Programming
    Replies: 1
    Last Post: 07-15-2002, 04:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21