User Profile

Collapse

Profile Sidebar

Collapse
runsun
runsun
Last Activity: Mar 18 '08, 03:37 PM
Joined: May 15 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • How can I format-output data from Mysql to a file?-relatively long

    I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than what I did. But I want to know what's wrong in my codes. Here are the details:
    In survey.html, I need people input their ID and comment.
    In Mysql, I've already made the survey table.
    I use survey_result.p hp to import people's input...
    See more | Go to post
    Last edited by ronverdonk; Mar 15 '08, 03:26 PM. Reason: code tags

  • runsun
    replied to A simple question about input a constant in C
    in C
    I tested. It is nothing to do with where functions declared. I think I did exactly as
    the code provided. Here are first part of my code and the error message:

    Code: ( c )
    #include <stdio.h>
    void main ()
    {
    int max;
    int a[10], i;
    printf ("enter total number: ");
    scanf ("%d", &max);
    const int maxmium =...
    See more | Go to post

    Leave a comment:


  • runsun
    replied to A simple question about input a constant in C
    in C
    I think this may be the problem:
    I define all the functions; then a number is inputted and it is defined as a constant (say, y, using the code that weaknessforcats posted); after that, the functions are called.
    I guess the functions should be defined after the constant is defined, because come of them use the constant (y).
    I'll try this soon......
    See more | Go to post

    Leave a comment:


  • runsun
    replied to A simple question about input a constant in C
    in C
    I tried. It does not work......
    See more | Go to post

    Leave a comment:


  • runsun
    started a topic A simple question about input a constant in C
    in C

    A simple question about input a constant in C

    I want to input (scanf) an integer, then treat (or define) it as a constant. How do I do?
    See more | Go to post

  • I find a way to write data into the array. Now the problem is since the numbers of elements are not same in different cell, when printf %c, some strange characters may appear.
    [code=c]
    #include <stdio.h>
    #include <stdlib.h>

    void main( )
    {
    char out_char;
    char array[3][2][5];
    int i, j, k;
    FILE *pfile = NULL;
    char *filename = "data.prn";...
    See more | Go to post
    Last edited by AdrianH; Jun 10 '07, 07:38 PM. Reason: Please use [code=c][/code] to increase readability!

    Leave a comment:


  • read data from file, write into 3D array - need help again.

    Thanks in advance. This program is written in C.
    It needs to read all characters from a file; then write them into a 3D array (yes, 3D!).
    The file is a .prn file (one of the Excel types), which separates columns with space.
    To simplify the question, the file contains 3 rows and 2 columns:
    abc 2,3
    defg 4
    h 5,6

    array is array[3][2][5], where the 3rd D contains the # of rows; 2nd D has...
    See more | Go to post
    Last edited by AdrianH; Jun 10 '07, 07:37 PM. Reason: Please use [code=c][/code] to increase readability!

  • With the help and hints I got from here, I figure it out!
    The key is array of pointers needs to be used instead of pointer to array.
    I tested the following code. It works. Note that it is not necessary to initiate int i=0;
    Many thanks to Savage and AdrianH!

    [code=c] int i, k;
    char str[4][6]={"adevf", "dcdhn", "oledc", "brdca"};
    char chr[3]={'a', 'b', 'c'};...
    See more | Go to post
    Last edited by AdrianH; Jun 6 '07, 12:44 PM. Reason: Change to use [code=c][/code] tags to improve readability.

    Leave a comment:


  • Thanks!
    line 10 gets the results of strchr, putting them in that two dimensional array. I think the problem is the pointer in line 10. But I don't know how to solve it.
    I think i is initialized, see line 1. (is it right?)...
    See more | Go to post

    Leave a comment:


  • runsun
    started a topic question about pointers in a 2-D array and strchr
    in C

    question about pointers in a 2-D array and strchr

    four strings are in a 2-D array; use strchr to find characters a, b, c, respectively;
    search results are to be put in another 2-D arrray ter[ ][ ]:
    results of searching 'a' in the 1st string go to ter[0][0], 'b' to ter[0][1]...
    ... 2nd string to to ter [1][0], 'b' to ter[1][1]...
    ...
    here are the codes:
    ...
    [code=c] int i, k;
    char str[4][6]={"adevf",...
    See more | Go to post
    Last edited by AdrianH; Jun 5 '07, 06:30 PM. Reason: Please use [code=c][/code] tags for improved reability.

  • Thank you very much!
    Not only did you answer this extension question, but also answered those related to my previous questions!...
    See more | Go to post

    Leave a comment:


  • That works well. Thank ghostdog74!...
    See more | Go to post

    Leave a comment:


  • runsun
    started a topic How to add an extension to an input filename?

    How to add an extension to an input filename?

    Read from an existing file, then output a file with the same name but an extension:

    file = raw_input ('Enter the filename:\n')
    fileout = open ('file.out', 'w')

    However, when I enter a filename like "test", it gives the output file as "file.out" instead of "test.out".
    See more | Go to post

  • runsun
    replied to need help in output table
    Among the solutions, this looks like the simplest and most efficient one.
    The only problem is that the output includes some symbols. For example:
    the 1st row is
    ['01\n', '03\n', '05\n']

    Since I deal with numbers, I first convert them to int or float, then the output is what I want now:
    01 03 05

    Although I still don't know how it works if them are strings.
    Thanks a lot!!!...
    See more | Go to post

    Leave a comment:


  • runsun
    replied to Line Numbers
    The first one works - it seperates odd and even lines. However, the odd_lines in the output are not in one row; so are the even_lines....
    See more | Go to post

    Leave a comment:


  • runsun
    replied to Line Numbers
    I tried the 1st one. It worked when using ...open('file') : in line 2.
    But I have a further question:
    How does this work:
    read the 1st, 3rd ... lines, then output them in the 1st row (seperated by space);
    read the 2nd, 4th ... lines, output in the 2nd row;
    ...

    I used several loops. None of them worked....
    See more | Go to post

    Leave a comment:


  • runsun
    started a topic need help in output table

    need help in output table

    want to read selected lines in a file, then output in one row.
    For example:
    read the 1st, 3rd ... lines, then output them in the 1st row;
    read the 2nd, 4th ... lines, output in the 2nd row;
    ...

    I used several loops. None of them worked.

    Thanks.
    See more | Go to post
No activity results to display
Show More
Working...