Jump to content

rubing

Members
  • Posts

    366
  • Joined

  • Last visited

    Never

About rubing

  • Birthday 02/10/1976

Profile Information

  • Gender
    Male
  • Location
    Birmingham, AL

rubing's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. yeah, you can write this kind of stuff to a simple text file using the fopen and associated fcns.
  2. that's wierd...i'm not sure i like that :-\ Is there someone over at ANSI, I can complain to about this ???
  3. I don't understand. In this code snippet there is a function called getline which accepts 2 parameters: line : which is defined as character array, but is initially empty MAXLINE : which is the max length of a line for our testing purposes [1000 characters; prevents overflow] getline returns the number of characters in the line. It should not alter either of the parameters MAXLINE or line, except within the scope of that function. Am I incorrect? while ((len=getline(line,MAXLINE)) > 0) if (len > max) { max=len; copy(longest,line); }
  4. The character array line is changes in the getline function, which seems fine. But then in the if statement that follows that character array is being fed into copy, which seems like it should be outside its scope??
  5. Hey, (corbin I assume ) I am working through another example. This is a small program composed of 2 functions which takes a standard input of many lines and determines the longest. It then prints the longest. I do not understand how the second function called copy is obtaining the character array for the longest line. I am thinking that maybe there is something different about the scope of parameters in C from php, which makes this possible...i don't know. your wise counsel is appreciated! Here is the code: #include <stdio.h> #define MAXLINE 1000 int getline(char line[], int maxline); void copy(char to[],char from[]); main() { int len; int max; char line[MAXLINE]; char longest[MAXLINE]; max=0; while ((len=getline(line,MAXLINE)) > 0) if (len > max) { max=len; copy(longest,line); } if (max > 0) printf("%s", longest); return 0; } int getline(char s[], int lim) { int c,i; for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i) s[i]=c; if (c== '\n') { s[i] = c; ++i; } s[i]='\0'; return i; } void copy (char to[], char from[]) { int i; i = 0; while ((to[i]=from[i])!='\0') ++i; }
  6. ooooh...that's tricky! but I get what your saying. We're just converting the ascii value to actual integer value. It also took me a while to figure out that EOF line, but I did pipe some file into it and it worked. This is one of the classic texts on C programming so, its surprising that wasn't made clearer.
  7. I have the following code that determines the number of digits (0, 1, 2, 3, etc..), whitespace, and characters in a file. I don't understand why the line in red (++ndigit[c-'0'] can't be written merely as ++ndigit[c]? Thanks! #include <stdio.h> main() { int c,i,nwhite,nother; int ndigit[10]; nwhite=nother=0; for (i=0; i<10;++i) ndigit[i]=0; while ((c=getchar())!=EOF) { if (c>='0' && c<='9') [b][color=red]++ndigit[c-'0'];[/color][/b] else if (c == ' ' || c=='\n' || c=='\t') ++nwhite; else ++nother; } printf("digits ="); for (i=0; i<10; ++i) printf(" %d",ndigit[i]); printf(",white space=%d,other=%d\n",nwhite,nother); }
  8. I am following along with exercises from a book (C Programming), and one of the examples doesn't seem to be working. I believe it's supposed to print the number of characters you enter, but it doesn't do anything. Is there something wrong with my code? #include <stdio.h> main() { long nc; nc=0; while (getchar() != EOF) ++nc; printf("%ld\n",nc); }
  9. If cl_id is a number than you don't need quotes around it in your query. that's probably the problem...sql trying to compare a string to an integer Try that and then if that doesn't work start profiling it by throwing some echo statements in there??? <?php error_reporting(E_ALL); ini_set('display_errors', '1'); include '../library/config.php'; include '../library/opendb.php'; $cl_ID = $_GET['cl_ID']; if(isset($_POST['submit'])) { $cl_course = addslashes($_POST['cl_course']); $cl_day = addslashes($_POST['cl_day']); $result = mysql_query("UPDATE classes SET cl_course='$cl_course', cl_day='$cl_day' WHERE cl_ID='$cl_ID' ",$conn); } elseif($cl_ID) { $result = mysql_query("SELECT * FROM classes WHERE cl_ID='$cl_ID' ",$conn); while($myrow = mysql_fetch_assoc($result)) { $cl_course = $myrow["cl_course"]; echo $cl_course; $cl_day = $myrow["cl_day"]; echo $cl_day; ?> <form method="post" action="<?php echo $PHP_SELF ?>"> <table> <input type="hidden" name="cl_ID" value="<? echo $myrow['cl_ID']?>"> <tr> <td>Course:</td><td><input name="cl_course" size="40" maxlength="255" value="<? echo $cl_course; ?>" /></td></tr> <tr> <td>Day: </td><td><input name="cl_day" size="40" maxlength="255" value="<? echo $cl_day; ?>" /></td></tr> </table><br /> <div align="center"><input type="submit" name="submit" value="Update Class" /></div> </form> <? } } ?>
  10. Don't worry that's simple. When you submit an html form, they are stored in a php array called $_POST for example if you submit the following value <input name="question1" value="yes" /> then in php you can get the value will be stored here: $_POST['question1']
  11. there should be some kind of system by which people can progress ranking. ideally, i think the basis of this should be how many times you have been thanked for help.
  12. If you want me to write it, you should post this in the freelance section and let me know how much moola you will pay me. Now if you want help writing it we will give that to you free. Why don't you just ask us how to do a single thing? or try doing something yourself and tell us how it failed.
  13. I imagine something like this would work: http://webxadmin.free.fr/article.php?i=387
  14. yes this is very simple. again: 1. you store all your info in a database. 2. you query the database & store the resulting info in variables using php. 3. you populate your form with these variables. You should probably start by figuring out how to connect to your DB using php. I don't know what else to tell you dude i am giving you the theoretical background. now you have to get a book and start working through it or pay somebody and they will do it for you. There are plenty of people here who would set something up like that for you very quickly.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.