[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

unrefferenced variable

Asked by deon123 in Miscellaneous Programming

Keep reading to view my question?

I have a text file that appears to be in some type of code.  


Here are the rules of the code (this is how the file was created.)

•      If a character is not an Alphabetic character do nothing to it.
•      If it is an alpha character shift it 3 backwards in the alphabet.
•      Don't forget to wrap the alphabet (e.g.. 'b' would become 'y')
•      Don't forget to handle upper and lower case (especially when wrapping.)

I am trying to  write a C program that will decode the file.  To do this the file should reverse the process.  

The input file is provided.  The program should read the input file, decode it, and write the output file.  Make sure that you check for proper opening of the file and print an error message if the file does not exist.  You should open the output file for write ('w').  Don't forget to close all files.

Here are some hints to get you started.

•      You will still pass non-alpha characters
•      You will shift up 3 letters (not back)
•      You will still need to wrap the ends of the alphabet
•      Remember that the computer thinks 'W'=87 (and 'w'=119)
•      fgets and fputs are your friends
•      You can assume a maximum length of the input line of 80
•      Your function should take the 2 strings for an argument

With completion with this question I will need the following to go along with the answer.
•      Your source code (in a .c or a .cpp file)
•      Your solution file (a .txt file with the decoded message in it)
•      A couple of paragraphs describing your approach to solving the problem.

This is one approach that was used by someone else:

//begin
initialize your variables

open files that you will need

      while not eof
            read input file
            call decode(instring, outstring)
            write output file
close files
//end
function decode(instring, outstring)

      initialize counter

      looping through string
      if alpha
            if upper
            process upper character
            if lower
            process lower character
      else
      pass non alpha charater
return from decode



Ql yb, lo klq ql yb-qexq fp qeb nrbpqflk:
Tebqebo 'qfp klyibo fk qeb jfka ql prccbo
Qeb pifkdp xka xooltp lc lrqoxdblrp cloqrkb
Lo ql qxhb xojp xdxfkpq x pbx lc qolryibp
Xka yv lmmlpfkd bka qebj. Ql afb, ql pibbm-
Kl jlob--xka yv x pibbm ql pxv tb bka
Qeb ebxoqxzeb, xka qeb qelrpxka kxqroxi pelzhp
Qexq cibpe fp ebfo ql. 'Qfp x zlkprjjxqflk
Abslrqiv ql yb tfpeba. Ql afb, ql pibbm-
Ql pibbm--mbozexkzb ql aobxj: xv, qebob'p qeb ory,
Clo fk qexq pibbm lc abxqe texq aobxjp jxv zljb
Tebk tb exsb percciba lcc qefp jloqxi zlfi,
Jrpq dfsb rp mxrpb. Qebob'p qeb obpmbzq
Qexq jxhbp zxixjfqv lc pl ilkd ifcb.
Clo tel tlria ybxo qeb tefmp xka pzlokp lc qfjb,
Qe' lmmobpplo'p tolkd, qeb molra jxk'p zlkqrjbiv
Qeb mxkdp lc abpmfpba ilsb, qeb ixt'p abixv,
Qeb fkplibkzb lc lccfzb, xka qeb pmrokp
Qexq mxqfbkq jbofq lc qe' rktloqev qxhbp,
Tebk eb efjpbic jfdeq efp nrfbqrp jxhb
Tfqe x yxob ylahfk? Tel tlria cxoabip ybxo,
Ql dorkq xka ptbxq rkabo x tbxov ifcb,
Yrq qexq qeb aobxa lc pljbqefkd xcqbo abxqe,
Qeb rkafpzlsboba zlrkqov, colj telpb ylrok
Kl qoxsbiibo obqrokp, mrwwibp qeb tfii,
Xka jxhbp rp oxqebo ybxo qelpb fiip tb exsb
Qexk civ ql lqebop qexq tb hklt klq lc?
Qerp zlkpzfbkzb albp jxhb zltxoap lc rp xii,
Xka qerp qeb kxqfsb erb lc obplirqflk
Fp pfzhifba l'bo tfqe qeb mxib zxpq lc qelrdeq,
Xka bkqbomofpb lc dobxq mfqze xka jljbkq
Tfqe qefp obdxoa qebfo zroobkqp qrok xtov
Xka ilpb qeb kxjb lc xzqflk. - Plcq vlr klt,
Qeb cxfo Lmebifx! - Kvjme, fk qev lofplkp
Yb xii jv pfkp objbjyboba.





This is what i have. it is suppose to take the input from the user and output Shakespeare's Hamlet but I am confused on what i am doing wrong. As fas as errors when i debug the problem it displays 0 errors and 1 warning and the 1 warning points to the bottom of the program where it displays char ch; and it says that char ch; is an unrefferenced variable.
I want to know what is wrong with my program and why is it not taking in the scrambled up text and automatically decoding the scrambled text and out putting William Shakespeare's Hamlet





#include <stdio.h>

void decode(char *inst, char *outst)
{
      int i=0;
      char ch;
      while(inst[i]!='\0')
      {
            ch = inst[i];
            if(ch>=65 && ch<=90)
            {
                  ch = ch + 3;
                  if(ch>90)
                  {
                        ch = ch - 90;
                        ch = 64 + ch;
                  }
            }
            else if(ch>=97 && ch<=122)
            {                        
                  ch = ch + 3;
                  if(ch>122)
                  {
                        ch = ch - 122;
                        ch = 96 + ch;
                  }
            }            
            outst[i] = ch;
            i++;
      }
      outst[i] = '\0';
}

int main()
{
      FILE *in;
      FILE *out;
      char infile[20], outfile[20];
      char instr[80],outstr[80];
      char ch;
      printf("Enter input file name: ");
      scanf("%s",infile);
      printf("Enter output file name: ");
      scanf("%s",outfile);
      in = fopen(infile,"r");
      out = fopen(outfile,"w");
      while(1)
      {
            fgets(instr,80,in);
            if(feof(in))
                  break;
            decode(instr,outstr);
            fputs(outstr,out);
      }
      fclose(in);
      fclose(out);
      return 0;
}
 
Related Solutions
Keywords: unrefferenced variable
Title
1 C programming
 
Loading Advertisement...
 
[+][-]11/28/05 08:21 PM, ID: 15377622Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Miscellaneous Programming
Sign Up Now!
Solution Provided By: brettmjohnson
Participating Experts: 4
Solution Grade: A
 
[+][-]11/28/05 08:17 PM, ID: 15377608Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/28/05 08:26 PM, ID: 15377640Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/28/05 08:32 PM, ID: 15377658Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/28/05 08:41 PM, ID: 15377693Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/28/05 08:44 PM, ID: 15377705Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/28/05 09:08 PM, ID: 15377811Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/29/05 01:26 AM, ID: 15378554Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/29/05 03:18 AM, ID: 15379065Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/29/05 05:32 AM, ID: 15379641Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/29/05 05:38 AM, ID: 15379684Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/29/05 08:00 AM, ID: 15380916Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/29/05 08:02 AM, ID: 15380935Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/29/05 10:25 AM, ID: 15382223Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 06:18 AM, ID: 15388092Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 06:37 AM, ID: 15388258Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/30/05 02:49 PM, ID: 15392455Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/30/05 10:54 PM, ID: 15394564Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/01/05 06:06 AM, ID: 15396179Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/01/05 07:42 PM, ID: 15402385Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/01/05 10:58 PM, ID: 15402912Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92