Thread: Pointer help

  1. #1
    Registered User
    Join Date
    Oct 2005

    Pointer help

    Hey guys I was trying to add a pointer to the code below to that it will also count ints that occur in one line in a text file for example if in one line there was:

    int j,l,k; int t; int p;.

    But my pointer is all wrong could someone point out where I went wrong?

    (I know this isnt the best way to do this using arrays but its the way I have to do it thanks.)

    char * ch = array;
    char array [200];
    ifstream file;; 
    	if (file.is_open()) 
                 while (file.getline( array, sizeof(array) ))
                           	if( ( ch=strstr ( array, "int " )) != 0 )
                              for (i =0; i <sizeof(array)  ; i++
                                if (array[i]==',')
    				if (array[i]==';')

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Just at first glance:
    char * ch = array;
    char array [200];
    You are assigning array to ch* before you declare array. Try switching the order of these lines.
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    You know, there are about half a dozen live threads from you all covering basically the same problem.

    Not only is this annoying, it's also really hard to give you any kind of advice in a coherent manner. If you're also playing this board off against several other boards as well, that's a huge flood of conflicting information. You're not going to solve the problem like that at all.

  4. #4
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    What do you mean, Salem?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  2. Quick Pointer Question
    By gwarf420 in forum C Programming
    Replies: 15
    Last Post: 06-01-2008, 03:47 PM
  3. Parameter passing with pointer to pointer
    By notsure in forum C++ Programming
    Replies: 15
    Last Post: 08-12-2006, 07:12 AM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM