Thread: compiler error

  1. #1
    Registered User
    Join Date
    Sep 2004

    compiler error

    I wrote fllowing for reading file line by line till I get end of file . I could not run it properly. I compile in VC++ but basic syntax is C only. PLease help me out !!!!!!

    Is this correct way to read file till end --------
    while(fgets(string1,sizeof(string1),text) != "/0")

    // ACIDlg.cpp : implementation file
    #include "stdafx.h"
    #include "ACI.h"
    #include "ACIDlg.h"
    #include "stdio.h"
    #include "math.h"
    #include "stdlib.h"
    #include "stdio.h"
    #include "iostream.h"
    #include "string.h"
    FILE *text;
    char string1[BUFSIZ];
    char *string2;
    char stri[10];
    void CACIDlg::DoDataExchange(CDataExchange* pDX)
    	DDX_Control(pDX, IDC_LIST1, m_strrr);
    //	DDX_Text(pDX, IDC_EDIT1, m_st);
    while(fgets(string1,sizeof(string1),text) != "/0")
     if ((string2 = strchr(string1, '\n')) != NULL)
          *string2 = '\0';

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > I compile in VC++ but basic syntax is C only
    But it's written in C++ - only C++ has all that class::member stuff

    > #include "stdio.h"
    Standard headers use <> not "" for inclusion

    > while(fgets(string1,sizeof(string1),text) != "/0")
    Because its
    while(fgets(string1,sizeof(string1),text) != NULL )

    Next time
    1. Use code tags
    2. Use the correct forum for your code
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 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. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM