Jump to content

Peter_APIIT

Members
  • Posts

    69
  • Joined

  • Last visited

Posts posted by Peter_APIIT

  1. Hello all of you, i totally a newbie to programming,linux and computer also.

     

    I wrote a program which calulate the days between the initlized date and date enter by user. After calculated, rreturn the days of week.

    Unfortunately, the calulation is not working. Any idea or recommendations ?

     

    Your help is greatly appreciated by me and others.

     

    /* 
    * File:   Date.c
    * Author: nicholas_tse
    *
    * Created on March 18, 2007, 7:56 PM
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include "Date.h"
    
    
    
    int Days_Of_Week(const struct U_Days *, const struct U_Months *, const struct U_Years *);
    
    
    int main(int argc, char** argv[]) 
    {
    static struct Days days = {1};
    static struct Months months = {1};
    static struct Years years = {2002};
    
    // ---------------------------------------------------	
    char *Date[7]= {"Tuesday", 
    				"Wednesday", 
    				"Thursday", 
    				"Friday", 
    		   		"Saturday", 
    				"Sunday",
    				"Monday"
    				};
    
    
    
    // ---------------------------------------------------
    
    int result;				
    
    struct U_Days *days_ptr;
    struct U_Months *months_ptr;
    struct U_Years *years_ptr;
    
    days_ptr = &u_days;
    months_ptr = &u_months;
    years_ptr = &u_years;
    
    // --------------------------------------------------
    
    do
    {
    	printf("Enter a day in integer: ");
    	scanf("%d", &days_ptr->days);
    
    	printf("Enter a month in integer: ");
    	scanf("%d", &months_ptr->months);
    
    	printf("Enter a year in integer: ");
    	scanf("%d", &years_ptr->years);
    
    	result = Days_Of_Week(days_ptr, months_ptr, years_ptr);
    	printf("\nThe date your enter equal to days of week is %s\n\n", Date[result]);
    
    }while(days_ptr->days >0 && days_ptr->days <32 || months_ptr->months >0 && months_ptr->months <13);
    
    
    
    return (EXIT_SUCCESS);
    
    }
    
    
    
    // -----------------------------------------------------
    
    
    
    int Days_Of_Week(const struct U_Days *days_ptr, const struct U_Months *months_ptr, const struct U_Years *years_ptr)
    {
    
    static struct Days days = {1};
    static struct Months months = {1};
    static struct Years years = {2002};
    
    // -----------------------------------------------------
    
    char *Date[7] = {"Tuesday", 
    				"Wednesday", 
    				"Thursday", 
    				"Friday", 
    		   		"Saturday", 
    				"Sunday",
    				"Monday"
    				};
    
    int days_of_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    int loop;
    int temp_days;
    int k;
    
    // ------------------------------------------------------
    
    if (years_ptr->years % 4 ==0)
    {
    	days_of_month[1] = 29;
    }
    else
    {
    	days_of_month[1] = 28;
    }
    
    
    
    for (k=0; days_of_month[k]<12; k++)
    {
    	temp_days = temp_days + days_of_month[k];
    }
    
    	// Why here the the loop won't calculate the total days;
    
    
    printf("\n%d", days_of_month[3]);
    printf("\nTotal of days is %d", temp_days);
    
    
    
    if (days_ptr->days % 7 == 1)
    {
    	return 0;
    }
    
    else if (days_ptr->days % 7 == 2)
    {
    	return 1;
    }
    
    else if (days_ptr->days % 7 == 3)
    {
    	return 2;
    }
    
    else if (days_ptr->days % 7 == 4)
    {
    	return 3;
    }
    
    else if (days_ptr->days % 7 == 5)
    {
    	return 4;
    }
    
    else if (days_ptr->days % 7 == 6)
    {	
    	return 5;
    }
    
    else if (days_ptr->days % 7 == 0)
    {
    	return 6;
    }
    
    
    }
    
    /* 
    * File:   Date.h
    * Author: nicholas_tse
    *
    * Created on March 18, 2007, 9:27 PM
    */
    
    #ifndef _Date_H
    #define	_Date_H
    
    struct U_Days
    {
    int days;
    }u_days;
    
    struct U_Months
    {
    int months;
    }u_months;
    
    struct U_Years
    {
    int years;
    }u_years;
    
    // ----------------------------------------------------
    
    
    static struct Days
    {
    int days;
    }days;
    
    static struct Months
    {
    int months;
    }months;
    
    static struct Years
    {
    int years;
    }years;
    
    
    
    
    #endif	/* _Date_H */

  2. I have a math.c file which uses the pow function from math.h but cannot run the project. I don't know what happen.

     

    Below is my math.c file:

     

    /*	program to print a table of powers	*/
    
    #include <stdio.h>
    
    /* this header file includes the pow() function */
    #include <math.h>
    
    int main()
    {
    int num;
    float rn;
    printf("Type in a number\n");
    scanf ("%d",&num);
    printf("\nHere is a table for the square\n");
    printf("cube, quartic and quintic for %d to %d:\n\n", num, num+4);
    printf("Integer\tSquare\tCube\tQuartic\tQuintic\n");
    
    	/* if read in as int must be converted to float for pow() */
     rn=num;
    
    	/* each specifier includes the same width as header, no decimal places with following tab*/ 
    printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n",
    	rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;
    printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n",
    	rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;
    printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n",
    	rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;
    printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n",
    	rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;
    printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n",
    	rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); 
    return 0;
    }

     

     

    Thanks for your help.

     

    Your help is greatly appreciated by me and others.

  3. I have the mandriva linux 2007 installed in my computer. I unable to start the netlink at boot time. I odn't know how to solve it by changing the configurations files.

     

    Thanks for your help.

     

     

    Your help is greatly appreciated by me and others.

  4. I have downloaded the ktorrent and libktorrent but i cannot install it failed dependencies due to glibc crash. I have heard that glibc developed by Red Hat has many issues. I don't know how to solve this.

     

    I have try typed urpmi ktorrent but also failed dependencies.

    I have try typed urpmi glibc and it displayed already installed. I was wonder what the terminal complaint that failed dependencies since i have glibc. libkotterent relate some of the functions from glibc.

     

    Your help is greatly appreciately by me.

     

    Thanks for your help.

  5. NETWORKING=yes

    GATEWAY=192.168.1.1

    HOSTNAME=nicholas_tse.nicholas_tse_proxy_server nichola

    s_tse

     

    Above is my /etc/sysconfig/netowork configuration files. I realised that when shut down computer, it cannot shutdown the postgrel because nicholas_tse host name is not there. Your help is greatly appreciated.

     

    How to permanently change the hostname because each i shut down and restart again it display the same host name which localhost.

     

    Thanks for your help,

  6. Below is my /etc/sysconfig/network

     

    NETWORKING=yes

    GATEWAY=192.168.1.1

    HOSTNAME=nicholas_tse.nicholas_tse_proxy_server nicholas_tse

     

    and /etc/hosts

    127.0.0.1 nicholas_tse.nicholas_tse_proxy_server nicholas_tse

     

    I have did what you told me but still can't connect to internet through proxy server. I configuredmy browser proxy server is nicholas_tse_proxy_server.

     

    Is it have to register a domain before set up a proxy server ?

  7. My /etc/hosts file is as below:

     

    127.0.0.1 nicholastse.org

     

     

    I want to put my domain name as APIIT.edu.my. Please help in this. I really is a stupid guy. Therefore, please forgive my stupidness.

     

    Your help is greatly appreciated by me and others who view this post.

     

    I hope that linux will become the no 1 choice among the computer consumers.

     

    Besides that, i also hope that GOD will blessed you.

  8. I have did according what you tell me. I have edit the file /etc/sysconfig/network. I added this line HOSTNAME=nicholastse.org to that file. Unfortunately, the browser complaint that unknown proxy host - . Is it have to register a domain first before it can set up a proxy server ? If not, then why is so many problem to set up a proxy server.

     

    Below is my /etc/sysconfig /network configuration file

     

    NETWORKING=yes

    HOSTNAME=nicholastse.org

     

    Please help in this issue.

     

    I know you are a great guy.

     

    Your help is greatly appreciated by me and others.

     

    I using konqueror as my web browser. I have changed the settings which is manually specify the proxy settings and automatic detect proxy settings. When i changed it to automatic, it displayed an error message which is could not find a usable proxy configuration script.

     

    I hope this will help. If you need more information, please let me know.

  9. How to add the host name in file /etc/sysconfig/network ?

     

    I am a stupid guy. Please forgive my stupidness.

     

    Why does't needs to add the host name in the file initrd ? Your explanation is greatly appreciated by me .

     

    Your help is greatly appreciated by me and others.

     

    I very admired you. You are my GOD in my heart.

     

    I won't forget your forever.

  10. I have checked the above post but it seems useless also. The post doesn't provide any guideline to install eclipse-CDT plugin. I also read the eclipse-CDT official install guide but i also cannot get it. Besides that, i also trp to type urpmi eclipse-cdt in terminal but i face many error because failed dependencies. It just continue complaint missing some packages. I have search the missing packages at rpmfind.net, freshmeat and sourceeforge.net but also can't get the dependencies issues solved.

     

     

    Therefore, i may needed you guys help me.

     

     

    Your help is greatly appreciated by me.

  11. I did it according your instruction. Unfortunately, the browser display an error message which is unknown proxy host. By the way, i checked my host name and the host name is not changed even though i typed

     

    host name (the name i want)

     

    but in the /etc/hosts file, it display my host name correctly. I don't know what happen is it. In terminal, it still display localhost after reboot or log of. I think i need to configure something at initrd. Is it true ? I just guess.

     

    Your help is greatly appreciated by me.

     

    Thanks iawn1974.

     

     

    A billion thanks to you. Hope GOD will blessed you.

     

    I have checked this file /etc/sysconfig/network but this file only contain one line which is NETWORKING=yes.

     

    I don't know whether this information will help but i just post it for additional information.

  12. I have Eclipse isntalled in my computer but i don't know how to install the c/c++ plugin. I have try to check the file system of the plugin files. These files seem strange for me because is a Java archive files. I never unzip a java archive before. I mainly use Eclipse to write C/C++ and java program.

     

    You help is greatly appreciated by me.

     

    Thanks for your help.

     

     

    [moved from Software by spinynorman]

  13. I have download the bittorent files to my pc but i can't install due to failed dependencies. I try to search the files and download it but i after downloaded the files. Something happen, i forgot it.

     

    When i typed urpmi bittorent file, display an error message which is continued to install even though doesn't not match the dependencies.

     

     

    Your help is greatly appreciated.

     

    Thanks for your help.

×
×
  • Create New...