Jump to content

crocski

Member
  • Posts

    325
  • Joined

  • Last visited

Posts posted by crocski

  1. i need a good html website i really dont know where to start

    Codecademy if you were asking for a place to learn. Trust me its great and its not clustered with too much information at once. The way its setup you'll never a website in a week time. 

     

    You basically just have to stick with it. 

     

     or you can try tutorialpointz

  2. I'm curious how members here on the forum use google. For example when you looking for information.

     

    Do you

    type coherent sentences.

     

    or

     

    Do you

    type the keywords that you are looking for.

     

    For example

    'How to fix a bicycle wheel'

    vs

    ' fix bicycle wheel'

     

    I'm asking because I've seen people type paragraphs into google expecting to find anything.

     

    BTW I'm the second option. 

     

    Which one are you ?

  3. Do what most people do and start off with HTML then move to either php or javascript. HTML is simple easy to learn. Then move to making it work with javascript or/both php which is a different programming style. After you learned one of those two then look in to python, java or C, C#, C++.

     

    Main thing when programming is understanding the syntax.

    Algorithms are good for truly building code. IMO once you've grasp how algorithms are written; you can turn the syntax over so much quicker.

     

    I'd recommend C after learning html and javascript.

    Javascript is a beautiful language that Im just starting to realise.

  4. this

                   printf(" Sorting Projects ... ");               for (x=0; x<numprojects+1; x++)               for (n=x+1; n<numprojects+1; n++)

    should be something like this, i believe

                   printf(" Sorting Projects ... ");               for (x=0; x<numprojects-1; x++)               for (n=x+1; n<numprojects; n++)

    but now, what's your main problem?

    I think ill just have to occupy of the array for my project file to come back.

    though it does not print if I add more than one.

     

    how does my code look ?

     

    also with my current setup. How can read space in between text

    I tried 

    char name [30];printf("Enter your name: ");scanf ("%[\^n]", name);printf ( "Name entered : %s");

    this works but its self. Doesn't work otherwise.

  5.  

    I have define maxprojects already.

     

    do you mind if I share the entire code.

     

     

    Also (unrelated) I have realised that when I am inputting data; unless I use near all the array, it wouldn't print them in order.

     

    For instance -I have been test the input field with my name which is 7 char long, the array is set to 30, when I am over 10 or higher on all the entries it prints them all back to me in the order I put them in.

     

    Why is that?

     

     

    ok I have published the code. it is over 400 lines long.

     

    http://pastebin.com/XbdLK4yx

     

    noted this code is the older version of what I am using; as I when back to see what I was doing wrong and near close to what I'll actually use.

     

    hope for your feedback because I have no one close by that can assist.

  6. Here's an example I put together demonstrating how to use a struct to hold the record data.

     

    It prompts for a record name and then record id # then prints them back out when the user is finished.

     

    You might find it helpful.  :)

     

     
    #include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX_RECORDS 30#define MAX_NAME_LEN 20#define ERR_BAD_PTR -1#define NOERR       0/*    our struct for holding record data*/typedef struct{    long    m_recordId ;    char    m_recordName[ MAX_NAME_LEN ] ;} Record_t ;//tidiness typedeftypedef Record_t* RecordPtr ;voidflush( void ){    int c;    while( (c = getchar()) != '\n' && c != EOF );}intaddRecord( RecordPtr record ){    //if we're NULL, eject and let the caller know    if( !record )        return ERR_BAD_PTR ;    //Buffer for our input    char buf [ MAX_NAME_LEN ] ;    //force initialization to all 0    memset( &buf[0], 0, MAX_NAME_LEN ) ;    //if we are of size 0 or just a newline (user just hit enter) keep asking    while( buf[0] == '\0' || buf[0] == '\n' )    {        printf( "\nEnter record name: " ) ;        //get input from user        fgets ( &buf[0], MAX_NAME_LEN, stdin ) ;    }    //copy our buf into the record    strncpy( &(record->m_recordName[0]), &buf[0], MAX_NAME_LEN ) ;    //reset the buf and reuse it    memset( &buf[0], 0, MAX_NAME_LEN ) ;    //this pointer will tell us if strtol completely failed    char*   p = &buf[0] ;    //loop while strtol is unable to parse any numbers    while( p == &buf[0] )    {        printf( "\nEnter the record number: " ) ;        fgets ( &buf[0], MAX_NAME_LEN, stdin ) ;        //strtol will attempt to convert the entered characters in buf to a number.        //it will stop if a non-numeric character is encountered        record->m_recordId = strtol( &buf[0], &p, 10 ) ;    }    //all is good    return NOERR ;}intprintRecord( RecordPtr record ){    if( !record )        return ERR_BAD_PTR ;    printf( "\nRecord ID: %ld \nRecord name: %s \n", record->m_recordId, record->m_recordName ) ;    return NOERR ;}intgetRecords( RecordPtr recordList, size_t maxRecords ){    if( !recordList )        return ERR_BAD_PTR ;    size_t i = 0 ;    char add = 'y' ;    //quit looping if we reach maximum records or user aborts    for( ; i < maxRecords && (add != 'n' && add != 'N') ; i ++ )    {        int ret = addRecord( &recordList[i] ) ;        //if adding the record went OK, ask for another        if( ret == NOERR )        {            printf( "\nAdd another record (y/n)? " ) ;            add = getchar() ;   //in truth we actually only care if they enter n/N            flush();        }        //bad pointer, not really possible in this example        else if( ret == ERR_BAD_PTR )        {            printf( "\nNULL pointer at record %d\n", i ) ;            //return error            return ret ;        }    }    //we succeeded, return number of valid entries    return i ;}intmain( int argc, char** argv ){    //our list of records    Record_t records[ MAX_RECORDS ] ;    int r ;    r = getRecords( &records[0], MAX_RECORDS ) ;    if( r != ERR_BAD_PTR )    {        int i = 0 ;        //r is the number of records we entered, loop through them        for( ; i < r ; i ++ )        {            printf( "Printing record %d of %d \n", i+1, r ) ;            printRecord( &records[ i ] ) ;        }    }    return 0 ;}

     

    Sample output

     

    Enter record name: Carnival

    Enter the record number: 409

    Add another record (y/n)? y

    Enter record name: Soca

    Enter the record number: 333

    Add another record (y/n)? n

    Printing record 1 of 2

    Record ID: 409

    Record name: Carnival

    Printing record 2 of 2

    Record ID: 333

    Record name: Soca

    DUDE, thanks allot for your efforts, though it not what I was looking for. I am looking at your code as it is well explained and I've start to tamper with to full understand it and examine. Thanks for the breakdown; as I have seen allot of this syntax used but never knew what it does. So I appreciate it.

     

    Off-topic slightly:

    useCamelCaseForVariablesAndFunctions. easiertoreadthanaunrecognizablestringofletters :)

    Lol

     

     

     

    I think the initial solution posed wasn't explained properly and that was my fault.

    Instead of having the user input a primary key.

    My intend was to create an automatic number; between for example from (1 to 100).

    1 being the starting point; while it increments for a new 'set of data'.

    and prints it accordingly.

     

    Sad to say I have not made progress with this.

    I have been picking at it.

    Ive been busy and kinda put it on the backburner

     

    Thoughts?

  7. Try this:

    char entries[49];int p=50;printf("Please enter your number followed by the enter key");while (p != 0){printf("Please enter the next number");scanf ("%s", entries);p--;}int i;for (i = 0; i < 50 ; i++){printf ("ID: ", i);printf (" ENTRY NAME : ", entries[i]);}

    Let me know if it throws any errors.

    string need to but changed to char. ; after entries.

     

    also 

    this message

     

    |error: 'for' loop initial declarations are only allowed in C99 mode

     

    i have never seen this so I dont know what to do.lol

     

     

     

    EDIT: FIXED

×