User Profile

Collapse

Profile Sidebar

Collapse
mattmao
mattmao
Last Activity: Apr 3 '08, 12:51 AM
Joined: Aug 17 '07
Location: Sydney
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • [JavaScript]How to "auto" copy content of textbox to clipboard

    I am doing a ASP.NET porject, inside a asp control tag there are some textboxes for users to input data.

    Later they can take previously entered data out of those textboxes.

    To provide better UI efficiency, I would like to use JavaScripts to support "auto" copy to clipboard, but I don't know how to achieve that?

    Here is my code stub:
    Code:
    <script type="text/javascript">
    ...
    See more | Go to post

  • [ASP.NET2.0] How to invoke a javascript inside layouttemplate

    I created a customed layout template in which contains a TextBox and Button.
    Code:
    <layouttemplate>
        <asp:TextBox id="TxtUser" runat="server" />
        <asp:Button id="myButton" runat="server" OnClientClick="myJavascriptFunction" />
    </layouttemplate>
    The javascript looks like this:
    Code:
    <script type=text/javascript>
    function
    ...
    See more | Go to post

  • After several hours' work I change my design a little bit. Now it successfully demonstrates the Adding, Deleting and Listing functionalities :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    
    namespace lab02exec
    {
        public class Program
        {
            static void Main(string[] args)
            {
                ArrayList
    ...
    See more | Go to post

    Leave a comment:


  • mattmao
    started a topic [C#]proper inheritance/polymorphism design wanted
    in .NET

    [C#]proper inheritance/polymorphism design wanted

    I am brand new to C#.NET so here is my trial on this lab exercise:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    
    namespace lab02exec
    {
        public class Program
        {
            static void Main(string[] args)
            {
                ArrayList myContacts = new ArrayList();
    
                //switching user
    ...
    See more | Go to post
    Last edited by kenobewan; Mar 7 '08, 12:32 PM. Reason: Removed lab

  • mattmao
    started a topic [C#]An Array object is allocated in stack or heap?
    in .NET

    [C#]An Array object is allocated in stack or heap?

    Hello everyone, this is my first thread in this .NET forum.

    Since I am studying C#.NET in this semester, I reckon this would be just the right place for my asking questions regarding the C# language and the .NET framework:)

    I got some experience of ANSI C where you declare an array in stack, so:

    Code:
    int[10] myArray;
    would allocate a continous piece of memory in stack which can contain 10 integers...
    See more | Go to post

  • mattmao
    replied to linked list (Insert)
    in C
    Hello mate:

    Don't feel so bad about programming, have a break and come back later when your brain is recharged with energy again:)

    I sugest you think of dividing your function into smaller parts, say, one for creating the stack(in my case, I would use head and tail sentinels to help me), one for pushing the stack and another one for poping the stack.

    Then you can check each of those smaller code fragments...
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to about how to read a file and print it in C
    in C
    Hello Chris:

    Your logic is good, but there might be a tiny issue to take extra considerrations :
    You cannot tell the total "length" of the text before reaching the EOF tag, can you? Unless you use malloc to dynamically allocate enough memory space for a huge array, the content of file may sometimes overflow the boundary of the array.

    Thus personally I believe that it would be better to read the content...
    See more | Go to post

    Leave a comment:


  • Well, It seems that I worked it out:

    Code:
    #include "stdio.h"
    int main()
    {
    	char *numberWords[3] = {"one", "two", "three"};
    	int i;
    	
    	for(i=0;i<3;i++)
    		printf("%s   ", numberWords[i]);
    }
    This uses an array of pointers to characters, then I can visit any element in the array by its index. I wonder if...
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to about how to read a file and print it in C
    in C
    For question 2:

    Divide and conquer.

    If you can break the big task into smaller ones, say, line by line, then think about how to reverse a line of words. Hints are: fgets would give you the "line of words".

    For question 3:

    It is the old counting question again. Your program can count how many times it reads a character by fgetc, after finishing the whole text, check your note to...
    See more | Go to post

    Leave a comment:


  • Well, yeah. After reading the enumeration tutorial for one minute I realized that...

    Now my question comes back to the beginning one: which would be the proper data structure to hold such a "index" list of those 29 "number words"?

    I really don't want to be a guy that manually make 29 nodes and link them together to solve this problem. Reasons are obvious:
    1) It works, but in a dumb way....
    See more | Go to post

    Leave a comment:


  • After spending some time online, I found a very useful data structure: enumeration, which could be helpful to my question.

    I would try to figure it out myself, hope I am on the right track:)
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to about how to read a file and print it in C
    in C
    Another way to solve the first question would be like this:
    read the guidelines, no full code solutions.
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to about how to read a file and print it in C
    in C
    Hi

    fscanf(cfPtr,"% s",text);

    This means: read a "string" from file content and put it into the variable "text".
    Since a "string" can be terminated by space, tab or return, the fscanf function would stop right after it reaches the space character after the "I"...

    My suggestion:
    Think about using the function fgetc, it reads the file content...
    See more | Go to post

    Leave a comment:


  • [proper index architecture needed]Print out time in plain English

    Hi all.

    There is a challenge question I encountered recently, which says:
    "In plain English, there are six different ways when you want to tell someone else about the current time:

    It is five past seven.
    It is eleven to ten.
    It is half past nine.
    It is a quarter past eight.
    It is a quarter to ten.
    It is three o'clock.

    ...
    See more | Go to post

  • mattmao
    replied to c programming - float handling
    in C
    Think about the modular (%) operator......
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to Converting string to float
    in C
    Hi.

    Use this:

    Code:
    float num;
        char *temp;
        if(sscanf(str, "%f%*s", &num, temp))
    This can solve that particular problem....
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to Converting string to float
    in C
    Emmm, that is pretty strange.

    This is not a research at all, google the references online shouldn't be blamed for...

    This is some references regarding sscanf, I am looking at it:
    http://www.crasseux.com/books/ctutorial/sscanf.html
    http://www.cplusplus.com/reference/c...io/sscanf.html




    Yeah, you can use the return value of sscanf to check if input is valid...
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to Converting string to float
    in C
    Hi.

    There is a potentially useful function in the ctype.h lib for your consideration:

    Function: int isdigit (int c)
    Returns true if c is a decimal digit (`0' through `9').

    If you take the user input as a string, then you can use a loop to check each character to validate it.

    Also you can use another function: strtol
    http://www.gnu.org/software/libc/manual/html_node/P...
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to Question regarding malloc
    in C
    This is taken from my lecturer's reply...And I think that could end this discussion, it seems that he doesn't care too much about the meaning of allocating 100 double pointers...

    Thank you for all of the helps. I found learning to program in c is pretty straight forward and interesting. Next semester I would continue to study in C++ :)...
    See more | Go to post

    Leave a comment:


  • mattmao
    replied to Question regarding malloc
    in C
    Sorry, I don't quite follow you.

    I already mentioned the meaning of option B, it makes fully sense to me. And if you want to allocate some memory space for the size of 100 pointer to double (s), then you should do it that way.

    The original question is taken from a exam paper, so we shouldn't consider too much about the actual code implementation, anything that is legal should be recognized as a correct answer.
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...