#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Dublin, Ireland
    Posts
    4
    Rep Power
    0

    C programming - unscrambler help


    Hi,

    Today I was trying to write a programm in c that reads a word list from a file, and a list of scrambled input words seperated by newline characters, and print out the unscrammbled word by commas.

    The idea is to go through the word list and assign every word with an integer, where this integer is made up of every number being a prime number and multiplyed out. I tried the same for the input.

    Then the program shuld shearch for equivilent numbers and print the result.

    The thing is, I cant seem to get this to work. Could someone please look at my code, or give me some advice of how I could improve my code or advise me to an different approach.

    Thank you.

    Code:
    /* Program that unscambles a word list from a file and a list of scrambled list that is input
    
    Author: Kai R
    Date:	11/12/2012
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    
    #define MAX_STRING_LENGTH 300
    #define MAX_CHARACTERS_WORD_LIST 15000
    
    int Integer_calculation=0;											//Global varibles
    
    void calculate_value(char character_1, char character_2, int prime); //function prototype
    
    int main(void)
    {
    	int input_list[MAX_STRING_LENGTH];
    	int index_1 = 0, index_2=0, index_3=0;
    	int store[2][MAX_STRING_LENGTH];								//stores word position and value of integer
    	int store_input[2][MAX_STRING_LENGTH];							//stores word position and value of integer for input
    	int count_1=0, count_2=0;										//counts characters
    	int store_value;
    	int unscrabled_word[MAX_CHARACTERS_WORD_LIST] = {0};           //EDIT - Initilised to Zero
    	int character;
    	int error_1 = 1, error_2 = 0;
    	
    	FILE *file_pointer_1;
    	
    	/*Opens the word list and calculates the values of each word */
    	
    	file_pointer_1 = fopen("wordlist", "r");							//Open wordlist
    	
    	if(file_pointer_1 == NULL)										//terminates program if list wont open
    	{
    		printf("\nThe word list would not open");
    		exit(1);
    	}
    	
    	printf("\nThe world list opened succesfully\n\n");
    	
    	character = getc(file_pointer_1);								//reads first character
    	character = unscrabled_word[0];
    	
    	while(character != EOF)
    	{
    		calculate_value(character, 'a', 2);
    		calculate_value(character, 'b', 3);
    		calculate_value(character, 'c', 5);
    		calculate_value(character, 'd', 7);
    		calculate_value(character, 'e', 11);
    		calculate_value(character, 'f', 13);
    		calculate_value(character, 'g', 17);
    		calculate_value(character, 'h', 19);
    		calculate_value(character, 'i', 23);
    		calculate_value(character, 'j', 29);
    		calculate_value(character, 'k', 31);
    		calculate_value(character, 'l', 37);
    		calculate_value(character, 'm', 41);
    		calculate_value(character, 'n', 43);
    		calculate_value(character, 'o', 47);
    		calculate_value(character, 'p', 53);
    		calculate_value(character, 'q', 59);
    		calculate_value(character, 'r', 61);
    		calculate_value(character, 's', 67);
    		calculate_value(character, 't', 71);
    		calculate_value(character, 'u', 73);
    		calculate_value(character, 'v', 79);
    		calculate_value(character, 'w', 83);
    		calculate_value(character, 'x', 89);
    		calculate_value(character, 'y', 97);
    		calculate_value(character, 'z', 101);
                    calculate_value(character, '0', 103);
    		calculate_value(character, '1', 107);
    		calculate_value(character, '2', 109);
    		calculate_value(character, '3', 113);
    		calculate_value(character, '4', 127);
    		calculate_value(character, '5', 131);
    		calculate_value(character, '6', 137);
    		calculate_value(character, '7', 139);
    		calculate_value(character, '8', 149);
    		calculate_value(character, '9', 151);
    		calculate_value(character, ';', 157);
    		calculate_value(character, '*', 163);
    
    			
    		if(character == '\n')
    		{
    			store[0][index_1] = Integer_calculation;
    			store[1][index_1] = count_1;
    				
    			Integer_calculation =0;									//resets calculation for next word
    			index_1++;
    			
    			count_1 = count_2 + 1;
    		}
    		
    		count_2++;
    		character = getc(file_pointer_1);							//reads the next character
    		character = unscrabled_word[count_2];
    	}
    	
    	store_value = index_1 - 1;										//records how many lines in wordlist
    	
    	printf("All values for the word list have been calculated sucessfully\n\n\n");
    	
    	/* Reads user input */
    
    	printf("Enter list to be unscrambled:\t\x28Press double enter to confire input\x29\n\n");
    	
    	do																//reads input
    	{
    		character = getchar();		
    		input_list[index_2] = character;
    		
    		index_2++;
    	}
    	while(input_list[index_2-1] != '\n' || input_list[index_2-2] != '\n');		//terminates loop
    	input_list[index_2]='\0';												//adds null character
    	
    	/* Calculates the values for the input list */
    	
    	printf("\n\nCalculating values for input list");
    	
    	index_1=0;												//resets index
    	index_2=0;												//resets index
    	Integer_calculation =0;									//resets calculation
    	count_1=0;												//resets counter
    	count_2=0;												//resets counter
    	
    	character = input_list[index_2];								//reads first character
    	while(input_list[index_2] != '\0')
    	{
    		calculate_value(character, 'a', 2);
    		calculate_value(character, 'b', 3);
    		calculate_value(character, 'c', 5);
    		calculate_value(character, 'd', 7);
    		calculate_value(character, 'e', 11);
    		calculate_value(character, 'f', 13);
    		calculate_value(character, 'g', 17);
    		calculate_value(character, 'h', 19);
    		calculate_value(character, 'i', 23);
    		calculate_value(character, 'j', 29);
    		calculate_value(character, 'k', 31);
    		calculate_value(character, 'l', 37);
    		calculate_value(character, 'm', 41);
    		calculate_value(character, 'n', 43);
    		calculate_value(character, 'o', 47);
    		calculate_value(character, 'p', 53);
    		calculate_value(character, 'q', 59);
    		calculate_value(character, 'r', 61);
    		calculate_value(character, 's', 67);
    		calculate_value(character, 't', 71);
    		calculate_value(character, 'u', 73);
    		calculate_value(character, 'v', 79);
    		calculate_value(character, 'w', 83);
    		calculate_value(character, 'x', 89);
    		calculate_value(character, 'y', 97);
    		calculate_value(character, 'z', 101);
                    calculate_value(character, '0', 103);
    		calculate_value(character, '1', 107);
    		calculate_value(character, '2', 109);
    		calculate_value(character, '3', 113);
    		calculate_value(character, '4', 127);
    		calculate_value(character, '5', 131);
    		calculate_value(character, '6', 137);
    		calculate_value(character, '7', 139);
    		calculate_value(character, '8', 149);
    		calculate_value(character, '9', 151);
    		calculate_value(character, ';', 157);
    		calculate_value(character, '*', 163);
    			
    		if(character == '\n')
    		{
    			store_input[0][index_1] = Integer_calculation;
    			store_input[1][index_1] = count_1;
    				
    			Integer_calculation = 0;									//resets calculation for next word
    			index_1++;
    			
    			count_1 = count_2 + 1;
    		}
    		
    		count_2++;
    		index_2++;
    		character = input_list[index_2];									//reads the next character
    	}
    	
    	/* compares values that were calculated and prints word unscrambled*/ 
    	
    	printf("\n\nThe unscrambled words are:\t\x28Seperated by commas\x29\n\n");
    	
    	for(index_1=0; index_1 <= count_2; index_1++)
    	{
    		for(index_2=0; index_2 < store_value; index_2++)
    		{
    			if(store_input[0][index_1] == store[0][index_2])
    			{
    				for(index_3 = store[1][index_2]; unscrabled_word[index_3] != '\n'; index_3++)
    				{
    					putchar(unscrabled_word[index_3]);
    				}
    				
    				putchar(',');
    				
    				error_2 = 0;
    				
    				break;
    			}		
    			else 
    			{
    				printf("\nWord %i could not be decrypted", index_1+1);
    				
    				error_1 = 1;
    			}
    		}
    	}
    	
    	if(error_2 == 1 && error_1 == 1)
    	{
    		printf("\nThe words could not be decrypted");
    	}
    	
    	printf("\n\nProgram executed sucessfully\n\n");
    	
    	fclose(file_pointer_1);												//closes wordlist
    	
    	return 0;
    }
    
    
    void calculate_value(char character_1, char character_2, int prime) 	//calculates values
    {
    	if(character_1 == character_2)
    	{
    		if(Integer_calculation == 0)
    		{
    			Integer_calculation = prime;
    		}
    		else
    		{
    			Integer_calculation = Integer_calculation * prime;
    		}
    	}
    	
    	return;
    }

    EDIT: Initilised unscrambled_word array
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    What does the Wordslist file look like and what does the list to be unscrambled look like?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Dublin, Ireland
    Posts
    4
    Rep Power
    0
    Originally Posted by BobS0327
    What does the Wordslist file look like and what does the list to be unscrambled look like?

    Wordlist:
    Code:
    121212
    131313
    123123
    654321
    8675309
    666666
    696969
    888888
    1234567
    21122112
    12345678
    asdfjkl;
    hal9000
    bond007
    ncc1701d
    ncc1701e
    ncc1701
    thx1138
    a12345
    abcd1234
    1234qwer
    1a2b3c
    1q2w3e
    test123
    1p2o3i
    puppy123
    kitten12
    qwerty12
    john316
    apollo13
    ne1469
    amanda1
    mazda1
    angela1
    alpha1
    sarah1
    nirvana1
    bubba1
    scuba1
    rambo1
    charlie1
    david1
    digital1
    dragon1
    honda1
    shadow1
    eagle1
    freak1
    james1
    1sanjose
    apple1
    master1
    happy1
    martin1
    jason1
    larry1
    number1
    robert1
    soccer1
    direct1
    chester1
    welcome1
    french1
    hockey1
    chevy1
    scooter1
    chris1
    lucky1
    teddy1
    phoenix1
    hello1
    julie1
    kevin1
    pookie1
    viper1
    jenny1
    jesus1
    kelly1
    money1
    mouse1
    sting1
    justin1
    molly1
    sunny1
    front242
    jordan23
    2welcome
    h2opolo
    bird33
    4runner
    babylon5
    star69
    ib6ub9
    america7
    seven7
    number9
    porsche9
    barbara
    database
    banana
    bananas
    canada
    jamaica
    amanda
    valhalla
    samantha
    yamaha
    natasha
    alaska
    tamara
    zapata
    avatar
    basketba
    baseball
    basebal
    bastard
    nebraska
    banane
    abigail
    sabrina
    batman
    cocacola
    cascade
    cardinal
    claudia
    packard
    cannonda
    apache
    america
    canela
    camera
    caesar
    warcraft
    catalog
    chapman
    zachary
    alicia
    patricia
    carolina
    nicarao
    captain
    nautica
    pascal
    rascal
    camaro
    nascar
    deadhead
    adidas
    alexande
    airhead
    alexandr
    andrea
    gandalf
    grandma
    happyday
    indiana
    paladin
    miranda
    adrian
    dakota
    dallas
    mayday
    pandora
    sandra
    xanadu
    angela
    margaret
    stargate
    savage
    gateway
    athena
    ariane
    pearljam
    maryjane
    oatmeal
    pamela
    pantera
    vanessa
    graymail
    iguana
    jaguar
    galaxy
    gasman
    hannah
    hawaii
    mariah
    jonathan
    marshal
    martha
    nathan
    italia
    aikman
    saskia
    vanilla
    mailman
    animal
    animals
    impala
    attila
    marina
    mariposa
    nirvana
    arizona
    joanna
    january
    lakota
    avalon
    alyssa
    yomama
    montana
    mantra
    tazman
    tarzan
    starwars
    bobcat
    badboy
    barbie
    babies
    basketb
    rabbit
    bamboo
    rebecca
    abcdef
    abcdefg
    blackie
    excalibu
    campbell
    tacobell
    bigmac
    jsbach
    columbia
    buddha
    badger
    butthead
    bradley
    brenda
    bernard
    ladybug
    diablo
    blizzard
    brandi
    bandit
    brandon
    brandy
    beagle
    isabelle
    elizabet
    beanie
    beatles
    webmaste
    beaner
    beaver
    fireball
    beautifu
    gabriell
    gabriel
    poohbear
    bertha
    benjamin
    bailey
    beavis
    basket
    blaster
    albert
    blazer
    barney
    strawber
    braves
    buffalo
    football
    softball
    footbal
    foobar
    bigman
    gambit
    global
    malibu
    library
    brasil
    brazil
    rainbow
    obiwan
    kombat
    snowball
    marlboro
    snowbal
    playboy
    absolut
    wombat
    canced
    icecream
    chance
    celica
    cracker
    cancer
    access
    pacific
    chicago
    chocolat
    arctic
    clancy
    cactus
    ****head
    maddock
    medical
    claude
    sundance
    dancer
    crawford
    richard
    wildcat
    picard
    colorado
    conrad
    corrado
    changeme
    chelsea
    peaches
    research
    teachers
    teacher
    creative
    cleaner
    france
    challeng
    michael
    charlie
    archie
    hacker
    chanel
    rachel
    charles
    patches
    jackie
    janice
    jessica
    maverick
    metallic
    caroline
    special
    claire
    iceman
    maurice
    maveric
    veronica
    carrie
    cassie
    active
    slacker
    packer
    packers
    marcel
    coltrane
    carole
    lacrosse
    scarlet
    scarlett
    castle
    carmen
    pacers
    racerx
    stacey
    catfish
    californ
    francois
    francis
    falcon
    graphic
    logical
    garlic
    camping
    racing
    cougars
    cougar
    chiquita
    christia
    nicholas
    champion
    cynthia
    charity
    charlott
    champs
    caitlin
    victoria
    tricia
    patrick
    calvin
    monica
    macintos
    action
    picasso
    jackson
    malcolm
    coolman
    classroo
    carlos
    crystal
    compaq
    tomcat
    marcus
    cannon
    corona
    cyrano
    topcat
    tractor
    laddie
    undead
    edward
    maddog
    diamond
    donald
    woodland
    greenday
    danielle
    dreamer
    reader
    garfield
    alfred
    reading
    gerald
    garden
    ****head
    daniel
    ireland
    raider
    raiders
    daytek
    leonard
    dreams
    anderson
    darren
    sanders
    andrew
    retard
    tuesday
    asdfghjk
    asdfgh
    dragonfl
    florida
    friday
    asdfjkl
    digital
    godzilla
    douglas
    dragon
    harold
    rhonda
    zaphod
    howard
    shadows
    shadow
    thursday
    indian
    island
    lindsay
    lizard
    madison
    pyramid
    darwin
    tardis
    wizard
    majordom
    jordan
    dollars
    orlando
    portland
    ronald
    rodman
    raymond
    monday
    sunday
    password
    passwd
    jeanette
    sweetpea
    jaeger
    general
    eagles
    heather
    kathleen
    hawkeye
    elephant
    sheena
    theresa
    theatre
    whatever
    whateve
    amelie
    melanie
    elaine
    valerie
    jeanne
    yankees
    walleye
    please
    seattle
    weasel
    awesome
    netware
    teresa
    grateful
    frankie
    fireman
    ferrari
    farmer
    safety
    maggie
    georgia
    aggies
    imagine
    galileo
    goalie
    enigma
    mirage
    wrangler
    angels
    german
    orange
    oranges
    ranger
    garnet
    voyager
    garrett
    target
    health
    katherin
    sheila
    stephani
    sapphire
    asshole
    harley
    stealth
    whales
    ashley
    hammer
    herman
    theman
    hamster
    matthew
    panther
    hearts
    harvey
    jasmine
    mikael
    mailer
    melissa
    valentin
    lorraine
    alpine
    aliens
    tequila
    reality
    laurie
    alexis
    sammie
    maxime
    marine
    vampire
    insane
    painter
    petunia
    praise
    pirate
    sierra
    asterix
    xavier
    jasper
    lakers
    walker
    kramer
    market
    tanker
    wanker
    parker
    startrek
    skater
    maxwell
    stella
    montreal
    temporal
    sampler
    marley
    samuel
    napoleon
    espanol
    snapple
    planet
    lauren
    stanley
    apples
    players
    player
    raquel
    slayer
    travel
    walter
    lestat
    superman
    masters
    master
    tanner
    suzanne
    newpass
    peanut
    warren
    tiffany
    wolfgang
    flamingo
    farming
    fugazi
    franklin
    family
    fountain
    wolfman
    smashing
    virginia
    sailing
    training
    stingray
    giants
    guitar
    magnum
    morgan
    mustang
    gymnast
    august
    mishka
    harrison
    spanish
    shanti
    joshua
    kathryn
    shalom
    hansolo
    phantom
    thomas
    shannon
    hanson
    anthony
    sharon
    hatton
    author
    arthur
    nikita
    williams
    william
    raistlin
    olivia
    julian
    jasmin
    allison
    marilyn
    alison
    polaris
    sailor
    quality
    sylvia
    ironman
    mountain
    tinman
    marino
    martin
    marvin
    matrix
    nissan
    passion
    station
    tristan
    austin
    utopia
    warriors
    warrior
    artist
    travis
    krystal
    spanky
    sparky
    apollo
    salmon
    psalms
    larson
    royals
    taylor
    norman
    snowman
    sampson
    samson
    mozart
    watson
    saturn
    tattoo
    toyota
    sparrow
    parrot
    passwor
    qwaszx
    stuart
    taurus
    bubbles
    debbie
    bluebird
    bigbird
    pebbles
    robbie
    hobbit
    jimbob
    booboo
    december
    quebec
    robotech
    republic
    october
    public
    zxcvbnm
    broncos
    cowboys
    scooby
    cowboy
    firebird
    bigred
    bridges
    dogbert
    thunderb
    birdie
    blondie
    dilbert
    doobie
    blonde
    rosebud
    bigdog
    bulldog
    sunbird
    remember
    septembe
    homebrew
    herbert
    biteme
    bernie
    reebok
    rebels
    byteme
    brewster
    webster
    boogie
    junebug
    goblue
    goober
    shelby
    theboss
    kimberly
    zombie
    timber
    bonnie
    benoit
    business
    nesbitt
    bootsie
    bluesky
    brooke
    volleyb
    bullet
    blowme
    trouble
    butler
    boomer
    benson
    booster
    trebor
    buster
    bigfoot
    blowfish
    bright
    bowling
    biology
    gibson
    bull****
    robinhoo
    bookit
    wilbur
    bonjour
    symbol
    boston
    browns
    buttons
    button
    brutus
    cccccc
    electric
    science
    chicken
    cricket
    celtics
    cyclone
    connect
    concept
    soccer
    success
    church
    chucky
    scotch
    cloclo
    cuddles
    depeche
    mercedes
    frederic
    deutsch
    duckie
    wicked
    cinder
    director
    orchid
    dominic
    doctor
    cheese
    coffee
    fletcher
    gretchen
    college
    michelle
    michele
    speech
    chester
    celine
    eclipse
    pierce
    service
    colleen
    telecom
    welcome
    spencer
    center
    except
    secret
    chiefs
    fletch
    ****me
    ****er
    michell
    mitchell
    michel
    chipper
    hockey
    cheryl
    techno
    porsche
    hector
    cherry
    justice
    pickle
    mickey
    snicker
    snickers
    cookie
    cookies
    nicole
    police
    clipper
    mexico
    connie
    vincent
    prince
    princess
    picture
    pisces
    security
    cruise
    rocket
    puckett
    tucker
    clover
    computer
    compute
    mercury
    newcourt
    courtney
    cooper
    scooter
    coyote
    copper
    ****off
    scruffy
    fiction
    ****you
    gocougs
    christin
    christop
    chrissy
    christ
    christy
    school
    psycho
    politics
    knicks
    lincoln
    unicorn
    scorpion
    corwin
    sonics
    scorpio
    victor
    victory
    curtis
    trucks
    control
    compton
    moocow
    cosmos
    popcorn
    xcountry
    country
    scotty
    deedee
    dundee
    freddy
    dodger
    dodgers
    defense
    freedom
    fender
    legend
    deliver
    denise
    kennedy
    ledzep
    denver
    speedo
    speedy
    dexter
    friend
    friends
    doggie
    digger
    goldie
    redwing
    design
    doogie
    dougie
    golden
    hendrix
    thunder
    inside
    kinder
    redskin
    dookie
    lindsey
    dennis
    trident
    sendit
    sidney
    detroit
    spider
    strider
    donkey
    reynolds
    elwood
    redrum
    wonder
    notused
    student
    sydney
    windsurf
    oxford
    midnight
    dwight
    hotdog
    indigo
    kingdom
    snoopdog
    gordon
    phurivdli
    judith
    dolphin
    dolphins
    hotrod
    dorothy
    midori
    skidoo
    domino
    nimrod
    wisdom
    windows
    dustin
    stupid
    drizzt
    london
    studly
    voodoo
    peewee
    reefer
    eugene
    sweetie
    kleenex
    skeeter
    penelope
    steelers
    steele
    eeyore
    weezer
    jeffrey
    jennifer
    jenifer
    ferret
    reggie
    george
    wheeling
    genesis
    sergei
    energy
    hershey
    kenneth
    shelley
    helpme
    wheels
    promethe
    hermes
    stephen
    einstein
    jessie
    nellie
    leslie
    letmein
    zeppelin
    etoile
    nemesis
    internet
    pierre
    jewels
    jeremy
    jensen
    jester
    kelsey
    loveme
    people
    explorer
    wrestle
    letter
    wesley
    velvet
    western
    newuser
    steven
    popeye
    europe
    pepper
    express
    tester
    stever
    testtest
    sweets
    sweety
    tweety
    griffey
    golfer
    fisher
    spitfire
    flipper
    xfiles
    fozzie
    sunflowe
    flowers
    flower
    flyers
    forest
    surfer
    future
    ginger
    tigger
    google
    nugget
    gregory
    theking
    gopher
    gemini
    gilles
    piglet
    penguin
    guinness
    singer
    testing
    genius
    tigers
    gretzky
    gunner
    nguyen
    grover
    shirley
    memphis
    sunshine
    phoenix
    whitney
    zenith
    hootie
    sophie
    joseph
    huskers
    shelly
    mother
    thumper
    hornets
    hornet
    hunter
    shooter
    topher
    horses
    zephyr
    sherry
    millie
    willie
    olivier
    minnie
    winnie
    trixie
    jupiter
    killme
    killer
    mookie
    kermit
    kristen
    tinker
    kittens
    kitten
    pookie
    skipper
    miller
    soleil
    elliot
    little
    merlin
    simple
    smiles
    smiley
    online
    wolverin
    liverpoo
    iloveyou
    oliver
    louise
    violet
    silver
    sylvie
    mortimer
    swimmer
    emmitt
    monique
    pentium
    mittens
    niners
    intern
    winner
    tennis
    senior
    sniper
    sunrise
    winter
    tootsie
    puppies
    ripper
    sprite
    monkey
    smokey
    network
    newyork
    volley
    yellow
    russell
    lennon
    nelson
    looney
    loveyou
    protel
    wolves
    purple
    russel
    turtle
    memory
    summer
    monster
    vermont
    trumpet
    system
    newton
    yvonne
    runner
    preston
    entropy
    reznor
    sunset
    rooster
    property
    porter
    export
    trevor
    qwerty
    fluffy
    muffin
    snuffy
    golfing
    froggy
    kingfish
    fishing
    flight
    gofish
    goforit
    informix
    pinkfloy
    foxtrot
    frosty
    zhongguo
    knights
    knight
    nothing
    hunting
    wright
    shotgun
    lionking
    skiing
    vikings
    viking
    swimming
    running
    roping
    spring
    grumpy
    topgun
    groovy
    phillip
    philip
    whisky
    timothy
    smiths
    sunshin
    horizon
    history
    johnson
    johnny
    murphy
    houston
    python
    shorty
    kristin
    kristi
    million
    mission
    tintin
    vision
    spirit
    junior
    justin
    pumpkin
    punkin
    skinny
    stinky
    skippy
    kristy
    suzuki
    willow
    wilson
    moroni
    mirror
    morris
    stimpy
    winston
    poiuyt
    squirt
    spunky
    spooky
    monopoly
    molson
    moomoo
    stormy
    toronto
    snoopy
    support
    sports

    List to unscrable:
    oocclaac
    atkser
    314265
    islonw
    qomcap
    opoiek
    tparei
    lmeeph
    srecoo1t
    laaecn

    EDIT:
    Looking at the word list more closely I didnt realise that there where numberes and symboles too. I need to add those cases too, but it still should output something^^
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    Let's start with the basics..

    Code:
    character = getc(file_pointer_1);					//reads first character
    	character = unscrabled_word[0];
    unscrabled_word array is uninitialized. You've got to initialize it with some integer values.

    I'm not sure why you want to load the character integer variable twice as indicated above. Doesn't make any sense.

    Somehow I get the feeling that this is going to be a very long thread.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    You're really over complicating the whole assignment. Total up the total prime numbers for each character in each word in the word list file. I used a singlular linked list for this task. One field was the word and a second field contained the total of the prime numbers for each character in the word. I then calculated the total prime number for each character in the scrambled word and then searched thru the link list for that total number. If the number was found, I then printed out the unscrambled word and the scrambled word.

    The results of my code are as follows:

    found word oocclaac = poohbear

    found word atkser = charlie1

    314265 was not found in dictionary

    found word islonw = foobar

    found word qomcap = america7

    found word opoiek = deadhead

    found word tparei = gasman

    found word lmeeph = apache

    found word srecoo1t = scooter1

    found word laaecn = chris1

IMN logo majestic logo threadwatch logo seochat tools logo