#define's Profile User Rating: *****

Reputation: 1276 Grandmaster
Group:
Expert
Active Posts:
4,395 (2.34 per day)
Joined:
19-February 09
Profile Views:
41,817
Last Active:
User is offline 43 minutes ago
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
LandRover
Dream Kudos:
0
Expert In:
C/C++

Latest Visitors

Icon   #define has not set their status

Posts I've Made

  1. In Topic: Compare words from text file with array

    Posted 16 Apr 2014

    Don't you want to use a C string for the test word?

    	char words[100][40], test[40];
    
    



    Do you need the ampersand & here? :-

    	for(i=0;i<7;i++)
    	{
    		fscanf(myFile, "%s", &words[i]);
    	}
    
    



    Why not print the words in the array to check it is ok?


    It might be polite to close the file before reusing the pointer.

      fclose(myFile);
    
      myFile = fopen("document.txt","r");
    
    


    Changed test to a string (char array) and removed ampersand, which is not required with string.)

    	fscanf(myFile, "%s", test);
    
    



    The result of the string comparison is returned, you don't do anything with it. Print some information to the programmer or user.

      while(!feof(myFile))
      {
        for(i=0;i<7;i++)
        {
          int differ;
          differ = strcmp(words[i],test);
          if( differ )
            printf("The words are different. \n");
          else
            printf("The words are the same. \n");
        }
      }
    
    
  2. In Topic: Testing character array against array of characters

    Posted 16 Apr 2014

    Hi, when fgets reads a on line 73 and 78 what is the third character?. You can test it.

      fgets(buffer, STATE_SIZE, fp);
    
      if( buffer[2] == 0 )
        printf("null character\n");
      if( buffer[2] == '\n' )
        printf("newline character");
    
    
  3. In Topic: Isolating digits and then converting them to a string

    Posted 15 Apr 2014

    If num1 is 1999 and d is 10 then num1/d is 199 as an integer.
  4. In Topic: Isolating digits and then converting them to a string

    Posted 15 Apr 2014

    Line 28 puts a integer value into the character and not necessarily a character.

    You could try adding to the '0' character:

      str[j] = '0' + num1/d;
    
    


    should it be division or modulo division?
  5. In Topic: Need help for my project

    Posted 15 Apr 2014

    Hi. Welcome to DIC.

    The flag variable is a boolean variable so can be true or false, in C 0 is used for false and any other number for true often 1. A flag can be up or down.

    flag starts at 0 (false) and on line 47 y increases when this is so.

    When max y is reached the flag is set to 1 (true) and line 44 is executed decreasing y.

    So the flag tells which direction the ball is moving and is changed when a limit is reached.

My Information

Member Title:
Duke of Err
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Delta Quadrant
Years Programming:
12
Programming Languages:
C,C++,HTML,CSS

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Comments

Page 1 of 1
  1. Photo

    GryphonClaws Icon

    10 Jan 2013 - 01:15
    Thanks #define. I can't believe I missed such a simple detail.
  2. Photo

    raghav.naganathan Icon

    07 Nov 2012 - 20:40
    Dude...before your reputation changes, I would like to tell you that it(729) is a perfect cube :) Cheers :)
Page 1 of 1