Thread: Driving me crazy

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    14

    Angry Driving me crazy

    i have this problem for over a week now..
    How do i then search the AdapterName array..
    get to get each individual set of characters that make a string.
    i am using this method
    and the application just crashes upon load
    Code:
    /////////////////////////////////////////////////////////////////////////
    
    char AdapterName[8192];
    char *temp,*temp1;
    
    //AdapterName char array gets populated by
    
    if(PacketGetAdapterNames(AdapterName,&AdapterLength)==FALSE)
    {
    cout << "Unable to detect the network adapters installed on this box!\n";
    return -1;
    }
    
    temp=AdapterName;
    temp1=AdapterName;
    
    while ((*temp!='\0')||(*(temp-1)!='\0'))
    {
            if (*temp=='\0') 
            {
             strncpy(AdapterList[i],temp1,(temp-temp1)*2);
             temp1=temp+1;
             i++;
             }
    	
             temp++;	//Incrementing Original char Pointer
    
    }
    if anyone could help me out it would be really appreciated


    &#91;code]&#91;/code]tagged by Salem

  2. #2
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    I don't think you wanted to do this in the while condition

    (*(temp-1)!='\0')

    i'm not sure that the -1 is right

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    14
    Sorry OS is win2k..
    so chars are stored in unicode..

    can u tell me which struct or type
    i should be storing unicode chars in ?

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    14
    ok i will do that thank you..
    but is the logic in my loop flawed do u know?

    the end result of myloop

    is i want to be able to say characterArray[3]

    and it points the position of the starting string of characters stored there

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    14
    thanks ill give em a go

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    126
    well, it may be becaues you are using the logical OR operator(||) in the loop's conditional statement. Both (*temp!='\0') and
    (*(temp-1)!='\0') would have to be false. That might be the problem. I would try using AND (&&) instead of OR, or taking out the second part of that conditional completely.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This program is driving my crazy!
    By zyphirr in forum C Programming
    Replies: 8
    Last Post: 12-05-2008, 05:36 PM
  2. This is driving me crazy! 256 colors palette
    By manugarciac in forum C++ Programming
    Replies: 0
    Last Post: 04-29-2007, 05:36 PM
  3. this is driving me crazy
    By pinko_liberal in forum C Programming
    Replies: 12
    Last Post: 06-05-2004, 08:03 AM
  4. IE 6 and Banner Ads is driving me crazy
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-09-2002, 02:18 AM
  5. Replies: 0
    Last Post: 10-29-2001, 11:40 PM