VatooVatoo 21 Light Poster

What is "clear"?

Your program is not a C program. It is C++. I think it is better that this post would moved to C++ section.


Inside a class or structure (both are almost same thing in C++) you can not set member values because they are not still created.

VatooVatoo 21 Light Poster

Your code is alittle old. In old 16 bit systems like DOS 6.0 there is a different memory addressing system named "segment" and far mentioned how the pointer can access to segments. But in nowadays 32 bit systems addressing is not via segment so there is no need to mention far.

I mean you could re-write your program as below

void main()
{
int i;
char *s=(char *)0xb8000000l ;
*(s+2)='p';
*(s+4)='r';
*(s+6)='i' ;
*(s+8)='i' ;
*(s+10)='t';
}
VatooVatoo 21 Light Poster

You must post your code and ask for solving. ;)

VatooVatoo 21 Light Poster

Since you're going to stop at each newline anyway, reading a whole line into a buffer using fgets() would be simpler than reading each char into a buffer.

Yes, but if your file was not a text file, so you would face with some trouble ;)

VatooVatoo 21 Light Poster

mancode1007, I recommend you to read a file byte by byte and store in a buffer and assume all data is character type and then do any process you wish.

I mean after reading your file your buffer will have a string like this

"22333 Smith Alison 70\r\n12222 John Brown 80\r\n12345 Chris Ratcel 60\r\n"

so you could create a loop and separate your data as you wish. if you need to change a numerical string to integer use atoi or similar functions.

if you read a file byte by byte ypu will have more flexiblity.

VatooVatoo 21 Light Poster

In C++ a struct or class needs to have a name to have a user defined constructor. The compiler will also generate the usual compiler generated constructors, but you can't get at them normally.

VatooVatoo 21 Light Poster
VatooVatoo 21 Light Poster

You can buid a DLL and call from your .NET program.

VatooVatoo 21 Light Poster
VatooVatoo 21 Light Poster

Yes it is valid

because printf return number of written characters. but if printf did not return a value, this program would be valid.

this case is alittle hard to explain. %d in formatting string will look for suitable parameter, but if can not find it will put a dummy data availbale in memory so this program will work or it is valid.

VatooVatoo 21 Light Poster

dear austinslik,

please use code below. for sorting an array you could use one of sorting algorithms as below. here I use quick sort algorithm. you also could write bubble sort, insertion sort,.......

int iQuickSort( int aiBuffer[], int iLeft, int iRigth)    
{  
        int iRef, iTemp;
        int iLeftIndex, iRigthIndex;    
    
        iLeftIndex=iLeft;    
        iRigthIndex=iRigth;          
    
        iRef = aiBuffer[(iLeft+iRigth)/2];
        do 
        {
        while( aiBuffer[iLeftIndex]<iRef && iLeftIndex<iRigth)
            iLeftIndex++;
               while( iRef<aiBuffer[iRigthIndex] && iRigthIndex>iLeft )
                   iRigthIndex--;
               
               if(iLeftIndex<=iRigthIndex)
               {  
                  iTemp = aiBuffer[iLeftIndex];
                  aiBuffer[iLeftIndex] = aiBuffer[iRigthIndex];
                  aiBuffer[iRigthIndex] = iTemp;
                  iLeftIndex++;
                   iRigthIndex--;           
               }
    }
    while( iLeftIndex<=iRigthIndex );
  
      if( iLeft<iRigthIndex) iQuickSort( aiBuffer, iLeft, iRigthIndex );
      if( iLeftIndex<iRigth ) iQuickSort( aiBuffer, iLeftIndex, iRigth );

      return 0;         
}

int main(int argc, char *argv[])
{
    int i,j,x,y;

    int unsort[10] = { 34, 76, 12, 1, 56, 23, 65, 9089, 45, 63 };
    
    
    for (i = 0; i < 10; i++)
        cout<<unsort[i]<<" ";

     iQuickSort( unsort, 0, 9 );
 
        cout << "\n";    

    //SORTED ARRAYS 
    for (i = 0; i < 10; i++)
        cout<<unsort[i]<<" ";
        
        cout << "\n";    
        
        system("PAUSE");
        return EXIT_SUCCESS;
}
VatooVatoo 21 Light Poster

ANSI C is a structured language. Means, you must wait for finishing one thread and then start new one.

But you could write a kernel function for your programs. Your kernel function would manage your other routines like windows OS kernel. For example, your kernel function would check your keyboard, mouse, ports,...... and if it find any activity kernel will return activity type to main routine.

VatooVatoo 21 Light Poster

LoL
Guys I just want to help someone to solve his/her problem and I didnt know this code was very important.

I just write it on my workbench in afew minutes.

I think there is not any missing in my code just one point "putting null at the end of target string" for standard PC with using ANSI C.

here is the new one

void vStringToUpper( const char *pcInputStr, char *pcOutputStr )
{

     int iLength, iIndex;
     iLength = strlen( pcInputStr );
     
     for( iIndex=0; iIndex<iLength; iIndex++ )
     {
          if( pcInputStr[iIndex]>='a' && pcInputStr[iIndex]<='z' )
                    pcOutputStr[iIndex]=pcInputStr[iIndex]-32; 
          else
                    pcOutputStr[iIndex]=pcInputStr[iIndex];    
     }

     pcOutputStr[iIndex]=0x00;

}

NycNessyness you can add it like below:

void GetInfo(void)
{

    /***** Course Number *****/
    


    char tmpCourseNumber[10];

    
    printf("\n\nEnter one of the following course numbers. ");
    printf("\n");
    printf("(ABC101, HIS220, HOT707, ECO122, PLE888)\n ");
    scanf(" %s", &tmpCourseNumber); 
    

    vStringToUpper( tmpCourseNumber, courseNumber );

............
VatooVatoo 21 Light Poster

you can use this simple function.

void vStringToUpper( const char *pcInputStr, char *pcOutputStr )
{
     int iLength, iIndex;
     iLength = strlen( pcInputStr );
     
     for( iIndex=0; iIndex<iLength; iIndex++ )
     {
          if( pcInputStr[iIndex]>='a' && pcInputStr[iIndex]<='z' )
                    pcOutputStr[iIndex]=pcInputStr[iIndex]-32; // change to uppercase
          else
                    pcOutputStr[iIndex]=pcInputStr[iIndex];    
     }
}
VatooVatoo 21 Light Poster

which handles and messages?
can you explain more?

VatooVatoo 21 Light Poster

This is impossible to reduce size of data as you want.

You can use LZW algorithm or something like that but rate of reduction depend on data

VatooVatoo 21 Light Poster

you can use this, it is simple. :)

void vProcess( int a, int b, int c )
{
    if( c>=3 ) 
    {
        b++;
        c=0;
        vProcess( a, b, c );
        return;
    }
    if( b>=3 ) 
    {
        a++;
        b=0;
        vProcess( a, b, c );
        return;
    }
    if( a>=3 ) return; 

    cout << crap[a] <<" "<<crap[b]<<" "<<crap[c];
    cout <<"\n";
    
    c++;
    vProcess( a, b, c );

}
VatooVatoo 21 Light Poster

if we suppose you are using VC++ 7.0 or 8.0, ints and floats are often 32-bit, chars 8-bit, and doubles are usually 64-bit.

strings is not a base type.

VatooVatoo 21 Light Poster

Just wanted to introduce myself. I am programmer and work for a international company in istanbul. 30 years old, maried.

nice looking forum here.


I mostly used to program with C/C++/MFC and lately .NET. so I will probably have more questions than answers:)

anyhow.... Hello all. ;)