Thread: compilation error

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    92

    compilation error

    hi i downloaded a source-code from the net for testing. the source code folder contains around 40 files(.cpp + .h ) along with a readme.txt.

    for compilation they have given told to type "make".
    after typing "make" ....i got the following....

    $ make

    g++ -c -O2 -Wall bat_graph.cpp
    bat_graph.cpp: In method `int bat_graph::get_params ()':
    bat_graph.cpp:147: `sscanf' undeclared (first use this function)
    bat_graph.cpp:147: (Each undeclared identifier is reported only once
    for each function it appears in.)
    make: *** [bat_graph.o] Error 1



    what could be the possible error ? what does the compiler pointing ?

    you know, i went to line 147 of the code bat_graph.cpp (according to compiler's notification) , but i found nothing is wrong there.

    well, what i have found there i am writng below......
    ( code is big...so i am excerpting imporatant points)

    snippet from the code bat_graph.cpp ......

    Code:
    
     // blah.....
      
      char c;
        134   char *pp = Preamble;
        135   int stop = 0;
        136   char *tmp = new char[100];
        137 
        138   Nr_vert = Nr_edges = 0;
        139 
        140   while (!stop && (c = *pp++) != '\0'){
        141     switch (c) {
        142     case 'c':
        143       while ((c = *pp++) != '\n' && c != '\0');
        144       break;
        145 
        146     case 'p':
        147       sscanf(pp, "%s %d %d\n", tmp, &Nr_vert, &Nr_edges);
        148       stop = 1;
        149       break;
        150 
    
    // blah.....
    do you think is there anything wrong at line 147 ? i dont see any error....

    anyway, can you suggest what could be the problem by watching compiler's notification.

    the whole code is big enough so, i have given a snippet of the troublesome area notified by the compiler.

    any suggestion to remove error ?

    thanks
    blue_gene

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    At the top of the source file containing the error, add this line:

    Code:
    #include <cstdio>
    using namespace std;
    That might work.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    92
    ohh...yes. right. the same problem was also in other file . i have checked it.

    thanks
    blue_gene

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, 01:29 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM