473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

will someone help me fix the errors i am trying to make a ascii card deck

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #define ERROR 00404
  3.  
  4. #include<iostream>
  5. using namespace std;
  6. int argc;
  7. char *argv[];
  8. int main(argc,argv)
  9. {
  10.     FILE *ascii_fd, *card_fd;
  11.     int arg = 1;
  12.     int format = 80;
  13.     int color = 0;
  14.     int corner = 0;
  15.     int cut = 2;
  16.     int interp = 0;
  17.     int punch = 4;
  18.     int table = 4;
  19.     int form = 1;
  20.     int logo = 0;
  21.  
  22.     while ((arg < argc) && (argv[arg][0] == '-')) { /* command line arg */
  23.         if (strcmp(argv[arg],"-H80") == 0) {
  24.             format = 80;
  25.         } else if (strcmp(argv[arg],"-H82") == 0) {
  26.             format = 82;
  27.         } else if (strcmp(argv[arg],"-cream") == 0) {
  28.             color |= 0;
  29.         } else if (strcmp(argv[arg],"-white") == 0) {
  30.             color |= 1;
  31.         } else if (strcmp(argv[arg],"-yellow") == 0) {
  32.             color |= 2;
  33.         } else if (strcmp(argv[arg],"-pink") == 0) {
  34.             color |= 3;
  35.         } else if (strcmp(argv[arg],"-blue") == 0) {
  36.             color |= 4;
  37.         } else if (strcmp(argv[arg],"-green") == 0) {
  38.             color |= 5;
  39.         } else if (strcmp(argv[arg],"-orange") == 0) {
  40.             color |= 6;
  41.         } else if (strcmp(argv[arg],"-brown") == 0) {
  42.             color |= 7;
  43.         } else if (strcmp(argv[arg],"-stripe") == 0) {
  44.             color |= 8;
  45.         } else if (strcmp(argv[arg],"-round") == 0) {
  46.             corner = 0;
  47.         } else if (strcmp(argv[arg],"-square") == 0) {
  48.             corner = 1;
  49.         } else if (strcmp(argv[arg],"-uncut") == 0) {
  50.             cut = 0;
  51.         } else if (strcmp(argv[arg],"-right") == 0) {
  52.             cut = 1;
  53.         } else if (strcmp(argv[arg],"-left") == 0) {
  54.             cut = 2;
  55.         } else if (strcmp(argv[arg],"-both") == 0) {
  56.             cut = 3;
  57.         } else if (strcmp(argv[arg],"-interp") == 0) {
  58.             interp = 1;
  59.         } else if (strcmp(argv[arg],"-noprint") == 0) {
  60.             punch = 0;
  61.         } else if (strcmp(argv[arg],"-026comm") == 0) {
  62.             punch = table = 1;
  63.         } else if (strcmp(argv[arg],"-026ftn") == 0) {
  64.             punch = table = 2;
  65.         } else if (strcmp(argv[arg],"-029") == 0) {
  66.             punch = table = 4;
  67.         } else if (strcmp(argv[arg],"-EBCDIC") == 0) {
  68.             punch = 0;
  69.             table = 8;
  70.         } else if (strcmp(argv[arg],"-blank") == 0) {
  71.             form = 0; logo = 0;
  72.         } else if (strcmp(argv[arg],"-5081") == 0) {
  73.             form = 1; logo = 0;
  74.         } else if (strcmp(argv[arg],"-507536") == 0) {
  75.             form = 2; logo = 0;
  76.         } else if (strcmp(argv[arg],"-5280") == 0) {
  77.             form = 3; logo = 0;
  78.         } else if (strcmp(argv[arg],"-327") == 0) {
  79.             form = 4; logo = 0;
  80.         } else if (strcmp(argv[arg],"-733727") == 0) {
  81.             form = 5; logo = 0;
  82.         } else if (strcmp(argv[arg],"-888157") == 0) {
  83.             form = 6; logo = 0;
  84.         } else if (strcmp(argv[arg],"-FORTRAN") == 0) {
  85.             form = 6; logo = 0;
  86.         } else if (strcmp(argv[arg],"-help") == 0) {
  87.             fprintf( stderr, "\n%s [options] [input [output]]\n\n",
  88.                  argv[0] );
  89.             fprintf( stderr,
  90.             "Make a virtual punched card deck from an ASCII file.\n"
  91.             "If output is missing, output to stdout; if input is\n"
  92.             "also missing, input from stdin.  The options are:\n\n"
  93.             " -H80 -H82       columns per card (H80 default)\n\n"
  94.              " -cream -white -yellow -pink      card colors\n"
  95.             " -blue  -green -orange -brown     (cream default)\n\n"
  96.              " -stripe         color stripe, cream card (common)\n\n"
  97.              " -round -square  corners on cards (round default)\n\n"
  98.              " -uncut -both    which top corner is cut\n"
  99.              " -left  -right   (left default, right common)\n\n"
  100.              " -interp         this card has been interpreted\n\n"
  101.              " -026comm        what keypunch to use\n"
  102.             " -029 -026ftn    (029 default)\n"
  103.             " -EBCDIC         (uninterpreted and rare!)\n\n"
  104.              " -noprint        turn off printing in the punch\n\n"
  105.              " -blank -5081      what preprinted form to use\n"
  106.              " -507536 -5280   (blank default, all common)\n"
  107.             " -327 -733737\n"
  108.             " -888157\n\n"
  109.             );
  110.             exit(-1);
  111.         } else {
  112.             fprintf( stderr, "%s: unknown option %s;"
  113.                      " -help available\n",
  114.                  argv[0], argv[arg] );
  115.             exit(-1);
  116.         }
  117.         arg++;
  118.     }
  119.  
  120.     if ( (argc - arg) > 2 ) { /* too many arguments */
  121.         fprintf( stderr, "%s: too many arguments\n",
  122.             argv[0] );
  123.         exit(-1);
  124.     }
  125.  
  126.     if ( (argc - arg) < 1 ) { /* no arguments, program is a filter */
  127.         ascii_fd = stdin;
  128.         card_fd = stdout;
  129.     } else { /* at least one argument */
  130.         ascii_fd = fopen(argv[arg],"r");
  131.         if ( ascii_fd == NULL ) {
  132.             fprintf( stderr, "%s %s: invalid ascii file\n",
  133.                 argv[0], argv[arg] );
  134.             exit(-1);
  135.         }
  136.         if ( (argc - arg) < 2 ) { /* only one arguments */
  137.             card_fd = stdout;
  138.         } else { /* at least two arguments */
  139.             card_fd = fopen(argv[arg+1],"w");
  140.             if ( card_fd == NULL ) {
  141.                 fprintf( stderr, "%s %s: invalid card file\n",
  142.                     argv[0], argv[arg+1] );
  143.                 exit(-1);
  144.             }
  145.         }
  146.     }
  147.  
  148.     /* output file prefix */
  149.     fputc( 'H', card_fd );
  150.     fputc( '8', card_fd );
  151.     if (format == 80) {
  152.         fputc( '0', card_fd );
  153.     } else {
  154.         fputc( '2', card_fd );
  155.     }
  156.  
  157.     /* ready to process from ascii_fd to card_fd */
  158.  
  159.     while( !feof(ascii_fd)) {
  160.         char line[82]; /* size allows for H82 format */
  161.         int src_col = 1;
  162.         int max_col;
  163.         line[0] = ' ';
  164.         line[81] = ' ';
  165.         while (src_col < 81) {
  166.             int cur_char = fgetc(ascii_fd);
  167.             if ((cur_char == EOF) && (src_col == 1)) break;
  168.             if ((cur_char == EOF) || (cur_char == '\n')) {
  169.                 while (src_col < 81) { /* blank out card */
  170.                     line[src_col] = ' ';
  171.                     src_col++;
  172.                 }
  173.             } else if (cur_char == '\t') {
  174.                 do {
  175.                     line[src_col] = ' ';
  176.                     src_col++;
  177.                 } while(((src_col & 07) != 1)&&(src_col < 81));
  178.             } else {
  179.                 line[src_col] = cur_char;
  180.                 src_col++;
  181.             }
  182.         }
  183.         if (src_col == 1) break; /* avoid blank card for early EOF */
  184.  
  185.         /* put out prefix on card */
  186.         fputc( 0x80 | (color << 3) | (corner << 2) | cut, card_fd );
  187.         fputc( 0x80 | (interp << 6) | (punch << 3) | form, card_fd );
  188.         fputc( 0x80 | logo, card_fd );
  189.  
  190.         if (format == 80) {
  191.             src_col = 1;
  192.             max_col = 80;
  193.         } else { /* H82 */
  194.             src_col = 0;
  195.             max_col = 81;
  196.         }
  197.         while (src_col <= max_col) {
  198.             char even_ch, odd_ch; /* source characters */
  199.             int even_col, odd_col; /* corresponding 12 bit codes */
  200.             char first, second, third; /* packed for output */
  201.  
  202.             /* get two columns */
  203.             even_ch = line[src_col];
  204.             src_col++;
  205.             odd_ch = line[src_col];
  206.             src_col++;
  207.  
  208.             /* convert to card codes */
  209.             if (table == 1) {
  210.                 even_col = o26_comm_code[ even_ch ];
  211.                 odd_col = o26_comm_code[ odd_ch ];
  212.             } else if (table == 2) {
  213.                 even_col = o26_ftn_code[ even_ch ];
  214.                 odd_col = o26_ftn_code[ odd_ch ];
  215.             } else if (table == 4) {
  216.                 even_col = o29_code[ even_ch ];
  217.                 odd_col = o29_code[ odd_ch ];
  218.             } else { /* table == 8 */
  219.                 even_col = EBCDIC_code[ even_ch ];
  220.                 odd_col = EBCDIC_code[ odd_ch ];
  221.             }
  222.  
  223.             /* divide 2 columns into 3 bytes */
  224.             first = even_col >> 4;
  225.             second = ((even_col & 017) << 4)
  226.                    | (odd_col >> 8);
  227.             third = odd_col & 00377;
  228.  
  229.             /* output 3 bytes */
  230.             fputc( first, card_fd );
  231.             fputc( second, card_fd );
  232.             fputc( third, card_fd );
  233.         }
  234.     }
  235.  
  236.     fclose(ascii_fd);
  237.     fclose(card_fd);
  238. }
here are my errors
1>------ Build started: Project: .3, Configuration: Debug Win32 ------
1> 3.cpp
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(130): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(139): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(210): error C2065: 'o26_comm_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(211): error C2065: 'o26_comm_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(213): error C2065: 'o26_ftn_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(214): error C2065: 'o26_ftn_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(216): error C2065: 'o29_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(217): error C2065: 'o29_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(219): error C2065: 'EBCDIC_code' : undeclared identifier
1>c:\documents and settings\wigundlach\my documents\visual studio 2010\projects\.3\.3\3.cpp(220): error C2065: 'EBCDIC_code' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Mar 23 '12 #1
1 1678
donbock
2,426 Expert 2GB
The first several messages are warning you that fopen is deprecated for serious production code; and that fopen_s is preferred. It goes on to say you suppress these warnings by (I suppose) #defining macro _CRT_SECURE_NO_WARNINGS. You should check your online Visual Studio documentation for more information.

The last few messages warn you that lookup arrays o26_comm_code, o26_ftn_code, 029_code, and EBCDIC_code are undefined. Do you intend for them to be defined locally in this source file or referenced from another source file?
Mar 26 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: JC | last post by:
I am very new to programming and learning on my own. Why do I keep getting duplicate values using this code? I want to shuffle a deck of 52 cards. The logic seems right to me. Randomize For...
5
by: Richie Adler | last post by:
Does anyone know of a bitmap/resource/image collection for a Spanish card deck? I'm planning to create a new cardgame which requires this kind of deck (prototyping in Python and possible final...
2
by: Ben Taylor | last post by:
Hi, I am writing a program that uses different threads to handle various painting operations, I wondered if somebody could possible tell me if I create a new thread using...
0
by: AndyAFCW | last post by:
I am developing my first .NET application that connects to a SQL Server 2000 database and I am having a total nightmare :x :evil: I am running Windows 2000 with Visual Studio .NET version...
3
by: Christian Hamel | last post by:
As said in the topic? I understand that this security has been added following many viruses out there but we have an automated system that we need to put in place that send emails. Any idea?...
5
by: wishbone34 | last post by:
I've gotten help writing out these functions, and i know what they each do individually, but i can't figure out where to start in my main program, i want to enter a string of numbers and...
4
by: tvance929 | last post by:
Hey everyone, I created a theDeck class that creates a 52 card int List. Inside of this class I have a ShuffleCards method. I simply want 2 seperate decks that I can then shuffle and...
1
by: jswain | last post by:
Hi, Not sure if anyone can help with this or whether i'm posting in the correct section but here goes: I run my own server (windows 2003) and write most of my sites in ASP. I have thr friendly...
1
by: DanThMan | last post by:
Hi All, Here's how my data looks. Two tables. The first has all the data in "expanded" form, the second has just "ID" data in "pivoted" form. Here's the "expanded" table: DataID | RowID |...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.