CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 30

Thread: need files

  1. #1
    Join Date
    Feb 2006
    Posts
    65

    need files

    hello, if u dont remember me, i was writing a little program that checks if everything is working in target source file..

    i checked it several time on my computer but if someone could send me their old source files of any program, as long as it's big... so that my program will have to try hard

    u could publish them here, or send it to [Sid: Deleted Profane Email Address] (without all the underscores..)

    thanks alot!!!
    Last edited by Siddhartha; March 4th, 2006 at 10:06 AM.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: need files

    Is this supposed to be a joke or something? You think anyone will send someting to that email address?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Feb 2006
    Posts
    65

    Unhappy Re: need files

    umm... im sorry but that's my email.. i really not trying to do something bad here..
    would u prefer that i will publish my code here and u will check it on your computer and tell me how was it?
    moshe...

  4. #4
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: need files

    [ cleaned ]

    Regards,
    Siddhartha

    PS: Mosche, you need to read the Acceptable Use Policy. That was too close.

  5. #5
    Join Date
    Feb 2006
    Posts
    65

    Re: need files

    what could i do.. i wanted to publish my email and it is my email.... not to hert anyone i placed underscores so the word wont be published.. sorry

  6. #6
    Join Date
    Jun 2001
    Location
    Switzerland
    Posts
    4,443

    Re: need files

    Quote Originally Posted by moshe2
    what could i do.. i wanted to publish my email and it is my email.... not to hert anyone i placed underscores so the word wont be published.. sorry
    You can register a free email address with a zillion providers nowdays. And you can choose an alias that's not offensive.
    Gabriel, CodeGuru moderator

    Forever trusting who we are
    And nothing else matters
    - Metallica

    Learn about the advantages of std::vector.

  7. #7
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: need files

    Quote Originally Posted by moshe2
    what could i do..
    Do yourself a favour, make a new email address if you want to be taken seriously.

    I am very sure - no prospective employer is going to invite you for an interview on that one.

    And now, to save your thread - I would recommend that you post the code where you faced problems (use code tags) with an explanation on purpose; else, this thread looks pretty meaningless.

  8. #8
    Join Date
    Feb 2006
    Posts
    65

    Re: need files

    employer??? im 15 yearsold
    anyway, i will open myself a new email.

    any way, im relativly new here.. what are code tags?

    shouldn't i copy paste my code here?

  9. #9
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: need files

    Quote Originally Posted by moshe2
    employer??? im 15 yearsold
    I guessed that.
    Hence I said "prospective employer".

    Okay, post your code here, and put this [/CODE] tag around it (the first one without the slash).

  10. #10
    Join Date
    Feb 2006
    Posts
    65

    Exclamation Re: need files

    if you could just copy this to your compiler, run it on one or more of your projects or source files and tell me how did it go....
    thnks!!!

    Code:
    /* ALL RIGHTS RESERVED MOSHE PROGRAMMING */
    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    int main()
    { //main open
      string Fname; int a[16]={0}; char ch=' ',pch=' ',ppch=' ',type='n'; double b=0,c=0,d=0,e=0,f=0;
      cout<<"input file's name (c:/file.type):\n\n"; cin>>Fname;
      ifstream scan(Fname.c_str());
      if(!scan){cout<<"Error in input file! ";}
    if(scan)
    { //scan open
     while(scan.get(ch))
     { //while-scan open
      
      while(1<2) //demi-loops
        { if(pch=='/' && ch=='/' && type=='n') 
    {type='c'; a[0]=a[0]-2; a[12]=a[12]+2; a[11]++; a[13]++; break;}
          if(type=='c' && ch=='\n') {type='n'; a[9]--; break;} break;}
      while(1<2) //demi-loops
        { if(pch=='/' && ch=='*' && type=='n') {type='m'; a[0]--; a[11]++; a[12]++; a[14]++; break;}
          if(pch=='*' && ch=='/' && type=='m') {type='n'; a[0]--; a[12]++; break;} break;}
      while(1<2) //demi-loops
        { if(pch!='\\' && ch=='\"' && type=='n') {type='t'; break;}
          if(pch!='\\' && ch=='\"' && type=='t') {type='n'; break;}
          if(pch=='\\' && ch=='\"' && type=='n') {type='n'; a[7]--; break;}
          if(pch=='\\' && ch=='\"' && type=='t') {type='t'; a[7]--; break;}
          if(pch=='\\' && ch=='\'' && (type=='t' or type=='n')) {a[8]--; break;} break;}
    
       if(type=='n') {
          if(ch=='('){a[1]++;} if(ch==')'){a[2]++;}
          if(ch=='{'){a[3]++;} if(ch=='}'){a[4]++;}
          if(ch=='['){a[5]++;} if(ch==']'){a[6]++;}
          if(ch=='\"'){a[7]++;} if(ch=='\''){a[8]++;}
          if(ch=='\n'){a[9]++;} if(ch==';'){a[10]++;}
          a[0]++; }
       if(type=='t') {a[0]++; if(ch=='\"'){a[7]++;}}
       if(type=='c') {a[12]++;}
       if(type=='m') {if(ch=='\n'){a[11]++;} a[12]++;} if(ch=='\n'){a[15]++;}
       if(a[0]>2){ppch=pch;} if(a[0]>1){pch=ch;}
     } //while-scan close
     
      scan.close(); system("cls"); cout<<"FILE ANALYSIS ON "<<Fname<<":\n\n";
    cout<<"CODE ANALYSIS-\n";
     cout<<"number of *(* in use= "<<a[1]<<"\n";  cout<<"number of *)* = "<<a[2]<<"\n";
      cout<<"status of *()* -----> "; if(a[1]==a[2]){cout<<"OK.\n";} if(a[1]!=a[2]){cout<<"ERROR!!\n";}
     cout<<"number of *{* = "<<a[3]<<"\n";  cout<<"number of *}* = "<<a[4]<<"\n";
      cout<<"status of *{}* -----> "; if(a[3]==a[4]){cout<<"OK.\n";} if(a[3]!=a[4]){cout<<"ERROR!!\n";}
     cout<<"number of *[* = "<<a[5]<<"\n";  cout<<"number of *]* = "<<a[6]<<"\n";
      cout<<"status of *[]* -----> "; if(a[5]==a[6]){cout<<"OK.\n";} if(a[5]!=a[6]){cout<<"ERROR!!\n";}
     cout<<"number of * \" * is "<<a[7];
      b=(a[7]+0.6)/2; for(c=0.3;c<10000000;c++){if(c==b){c=-8; break;}}
      if(c==-8){cout<<" -----> OK!!\n";}  if(c!=-8){cout<<" -----> ERROR!!\n";}
     cout<<"number of * \' * is "<<a[8];
      d=(a[8]+0.6)/2;  for(e=0.3;e<10000000;e++){if(d==e){e=-8; break;}}
      if(e==-8){cout<<" -----> OK!!\n";}  if(e!=-8){cout<<" -----> ERROR!!\n";}
     cout<<"number of commands in file= "<<a[10]<<"\n";
      cout<<"number of code lines in file= "<<a[9]<<"\n";
      cout<<"number of code chars in file= "<<a[0]<<"\n\n";
    
    cout<<"COMMENTS ANALYSIS-\n";
     while(1<2) //demi-loops
     {if(a[13]==0 && a[14]==0){cout<<"this file doesn't contain comments of any kind.\n\n"; break;}
      cout<<"number of single-line comments (//) in file = "<<a[13]<<"\n";
      cout<<"number of multiple-line comments (/**/) in file= "<<a[14]<<"\n";
      cout<<"number of comments lines in file= "<<a[11]<<"\n";
      cout<<"number of comments chars in file= "<<a[12]<<"\n\n"; break;
     }
    
    cout<<"GENERAL FILE ANALYSIS-\n";
      cout<<"number of total lines in file= "<<a[15]<<"\n";
      cout<<"number of total chars in file= "<<a[0]+a[12]<<"\n";
      cout<<"average number of chars in file ~ "<<(a[0]+a[12])/(a[15])<<"\n\n";
    
      cout<<"general status of file= "; if(a[0]+a[12]<2){cout<<"EMPTY! "; f=1;}
        if(((a[1]==a[2])&&(a[3]==a[4])&&(a[5]==a[6])&&(c==-8)&&(e==-8))&&f==0){cout<<"OK! ";}
        if(((a[1]!=a[2])or(a[3]!=a[4])or(a[5]!=a[6])or(c!=-8)or(e!=-8))&&f==0){cout<<"ERROR! ";}
    } //scan close
    cin>>Fname;
    } //main close

  11. #11
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: need files

    Don't let it become that complicated.
    Don't use magic numbers (or characters). You used variable type to identify current state (read more at 'state automata'). But you can define enum of states instead of characters. Why do you use that array to store collected info? Use named variables instead. And don't be greedy for identifier length. Try to rework your code. It's not the question of correctness really, since it matters little if code is impossible to read. First make it readable, then make it work, debug, and make it even more readable.
    Code:
    enum State {
      NORMAL_CODE,
      LINE_COMMENT,
      BLOCK_COMMENT,
      CHARACTER_STRING
    };
    
    State type = NORMAL_CODE;
    int num_line_comments = 0;
    ...
    switch(type) {
      case NORMAL_CODE: {
        // write code handling normal code here
        
        // for example:
        if((pch=='/') && (ch=='/')) {
          type = LINE_COMMENT;
          num_line_comments++;
        }
      } break;
      case BLOCK_COMMENT: {
      } break;
    // etc.
    }
    "Programs must be written for people to read, and only incidentally for machines to execute."

  12. #12
    Join Date
    Feb 2006
    Posts
    65

    Question Re: need files

    im new in programming.. i did not understand why i need to change it if it works, and if it is reading a 40000 lined-file in less then a sec..

    anyway what is that enum and all those strage commands?

    moshe

  13. #13
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: need files

    Well, if you have a code like this (try to run it - it works fine, just input a number):
    Code:
    #include <stdio.h>
    
    char(a)(1),(l)((a)+(47)),(m)(l),(n)(getc(stdin)-(m));
    
    struct foo
    {foo(){l+=a,a=(~a+1^a)&!((~((m+=!(48^l))-!(48^l))+l)&&(l^48))+~0^(~a+1),putc((10^l)&!(l^48)+~0^10,stdout);}};
    
    int main()
    {
        delete[] new foo[n*n+n];
        return 0;
    }
    how are you going to modify it? To add functionality, to fix the bug, etc.? It's just impossible. You'll have to rewrite it from scratch. It's the same with code you posted. Not that exaggerated of course, but the idea is the same.

    What exactly you don't understand about code I posted in first message? It uses switch and enum - quite simple concepts, you can read about them anywhere.
    "Programs must be written for people to read, and only incidentally for machines to execute."

  14. #14
    Join Date
    Feb 2006
    Posts
    65

    Question Re: need files

    could you explain in a few words what are those functions?

    i didnt really understand what did you program in the last massage was supposed to do... and where is the bug.. but nevermind, i got the concept i think....

    instead of a[16], b,c,d,e........ i should write chartype[16] for exmp? to keep it organized?
    and the enum ans switch are for the same purpose? just to keep it easy to view? would it be better if it would just be shorter??

    thanks alot for your replay!!
    moshe

  15. #15
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    1,194

    Re: need files

    Quote Originally Posted by moshe2
    anyway, i will open myself a new email.
    If you want to keep your address, but use other names to announce in public:
    www.spamgourmet.com
    Please don't forget to rate users who helped you!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)