User Profile

Collapse

Profile Sidebar

Collapse
ltgbau
ltgbau
Last Activity: Oct 31 '22, 06:44 AM
Joined: Sep 21 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ltgbau
    replied to How to extract a byte from file/
    in C
    Code:
    FILE *file=fopen("file.in", "rb");
    BYTE buf;
    while(feof(file)==FALSE)
    {
    	int n=fread(&buf, 1, 1, file);
    	if(n>0)
    	{
    		// process here...
    	}
    }
    fclose(file);
    file=NULL;
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to Functions & Files
    in C
    i think your 3 functions are like these, try to use and modify them... :D:D:D
    Code:
    void printMyName()
    {
    	cout<<"Your name here"<<endl;
    	cout<<"Program descriptions here"<<endl;
    }
    
    int findLargest(int a, int b, int c)
    {
    	int largest=a;
    	if(largest<b)
    		largest=b;
    	if(largest<c)
    		largest=c;
    	return largest;
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to Need help - Nested Loops
    in C
    Code:
    for(int i=0; i<10; i++)
    {
         for(int j=0; j<i; j++)
         {
              cout<<" ";
         }
         for(int j=i; j<10; j++)
         {
              cout<<"*";
         }
         cout<<endl;
    }
    :D :D :D this will create a triangle from '*' characters.....
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to reverse
    in C
    Code:
    	// in this code i treat the input number as a string
    	// and i assume that the input is valid (it means the input is a number
    	// and it doesn't contant any non-numeric character...
    	cout<<"input a number:";
    	char strNum[10]="";
    	cin>>strNum;
    	cout<<endl;
    	// calculate sum and mul of all figures to form the input number
    	int sum=0;
    	int mul=1;
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to same class project need help
    in C
    you need include some header files
    i don't include here :D

    Code:
     void main() 
    {
    cout<<"Input a character and a integer number:"<<endl;
    char ch;
    
    int num;
    
    cin>>ch>>num;
    
    if(num<0)
    
    num=1;
    
    if(num%2==0)
    
    num++;
    
    system("cls");
    
    for(int i=0; i<num; i++)
    
    {
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to data sorting and caching in C
    in C
    for reference here
    you can search for more details about sorting algorithms in the net
    :D
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to File Processing
    in C
    sorry but i think you need give us more details so that we can help you effectively
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to How to use shell commands in C
    in C
    i have never programed in MAC OS, but in Windows there's a command - system() to do this, you can try in Mac OS
    Good luck :D
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to i can't find the answer. please help
    in C
    yes, the condition is not strict enough :D
    i don't know why he needs a recursive function to count the number of times character ???

    sorry for my mistake :)




    Code:
     [left]int count(char ch, char str[])
    
     
    {
    int cnt=0;
    [b]int len=strlen(str);[/b]
    [b]if(len<=0)[/b]
    [b]{[/b]
    [b]return 0;[/b]
    [b]}[/b]
    [b]else[/b] if(len==1)
    {
    if(str[0]==ch)
    cnt++;
    }
    else[/]
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to i can't find the answer. please help
    in C
    Code:
    int count(char ch, char str[])
    {
    	int cnt=0;
    	if(strlen(str)==1)
    	{
    		if(str[0]==ch)
    			cnt++;
    	}
    	else
    	{
    		if(str[0]==ch)
    			cnt++;
    		cnt+=foo(ch, str+1);
    	}
    	return cnt;
    }
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to warm up about function swap()
    in C
    i think it depends on compiler :D
    but i forgot return 0; in main function :(...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to array question
    in C
    see two bold command lines

    Code:
    #include<iostream>
    
    int FindLowNum(int [], int );
    
    
    int main()
    {
    
           const int arraySize = 20;
    
           int a[ arraySize ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
    
          int total = 0;
    
          // sum contents of array a
          for ( int i = 0; i < arraySize;
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to warm up about function swap()
    in C
    your program after corrected
    TESTED, OK!!!

    Code:
    #include<stdio.h>
    
    void swap(int &, int &);
    void main(){
    
    int num1, num2;
    
    printf("Enter 2 numbers > ");
    scanf("%d%d", &num1, &num2);
    
    if(num1 > num2)
    swap(num1, num2);
    
    printf("In ascending order: %d %d \n", num1, num2);
    }
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to Console output
    in C
    add this command line
    system("cls");
    to your code
    so it becomes
    Code:
    #include<iostream.h>
    #include<conio.h>
    main()
    {
       [B]system("cls");[/B]
       int x,y,z;
       cout<< " input x,y \n";
       cin>> x >> y;
       z=x+y;
       cout<< " z=" <<z<<"\n";
       getch();
    }
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to How to return array
    in C
    note: you have to free memory references by the returned pointer after using it
    See more | Go to post

    Leave a comment:


  • Code:
    #include <stdio.h>
    #include <conio.h>
    #include <io.h>
    
    char* BYTE2Bin(BYTE val)
    {
    	char *temp=(char*)calloc(8, sizeof(char));
    	for(int i=0; i<8; i++)
    	{
    		if(((val>>i)&0x01)==1)
    			temp[7-i]=0x31;
    		else
    			temp[7-i]=0x30;
    	}
    	return temp;
    }
    void Encode(char *infile, char *outfile)
    {
    	FILE *file=NULL;
    ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to C++ Site
    in C
    try
    1. http://www.cplusplus.com
    2. http://www.codeproject.com
    3. http://www.programmersheaven.com
    4. ...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to C++ Beginner
    in C
    yes, but you'd better to you a code editor to do that, example Turbo C++...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to Urgent need of code in C
    in C
    i think you need to read data structures and algorithms books
    search in the net...
    See more | Go to post

    Leave a comment:


  • ltgbau
    replied to rejecting an non numberic input in C
    in C
    scan input as string then check if exists any non-numeric character
    if exists then reject, otherwise accept
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...