Thread: Characters & String

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    2

    Characters & String

    I have try modifying my code to work, i tried different compilers and i"m still getting a link error message. please help me. I'm using Turbo C++
    insert
    Code:
    #include <conio.h>
    #include <stdio.h>
    #include<stdlib.h>
    #include <string.h>
    #include<ctype.h>
    void print(char [],char []);
    void change(char [],char []);
    int main()
    {
    FILE *input;
    char in[80],out[80];
    char *str;
    input = fopen("data.txt","r");
    if(input == NULL)
      { printf("Error opening input file\n");
        system("pause");
        return 0;
    }
     str=fgets(in,80,input);
    change(in,out);
    print(in,out);
    fclose(input);
    getch();
    return 0;       
    }
    void change(char in[],char out[])
    {int i;
    for(i=0;i<strlen(in);i++)
           {if(isalpha(in[i]))
               out[i]=toupper(in[i]);
            else
                out[i]=in[i];
            }
    out[i]='\0';
    }
    void print(char in[],char out[])
    {printf("Before: ");
    puts(in);
    printf("After: ");
    puts(out);
    printf("\n");
    }
    data.cpp

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by keisha View Post
    please help me. I'm using Turbo C++
    First off, consider getting a newer compiler. There are plenty of newer, free compilers. I mean let's face it, you didn't actually go out and buy Turbo C++. So go download a good new free compiler instead of an old-not-free compiler.

    You also didn't actually include what linker error you are getting.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    2
    OK that is the compiler we are required to use i know there are newer compiler, i have tried my code in other compiler and it still not running.

    Linker Error: Undefined symbol _system in module DATA.CPP

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Code:
    if(input == NULL)
      { printf("Error opening input file\n");
        system("pause");
        return 0;
    }
    system() is a windows function. To use it you need to include <windows.h>
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by keisha View Post
    OK that is the compiler we are required to use
    I somehow doubt your school has a contract with Borland for a 20 year old compiler.
    Quote Originally Posted by keisha View Post
    Linker Error: Undefined symbol _system in module DATA.CPP
    You need to get rid of your compiler, or at the very least, to reinstall it. Since you won't do the former, just get rid of the system call, and call getchar instead.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    system() is a windows function. To use it you need to include <windows.h>
    Maybe that is something specific to Turbo C++, because it shouldn't be part of windows.h, it should be in stdlib.h. It's a standard C function.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    Maybe that is something specific to Turbo C++, because it shouldn't be part of windows.h, it should be in stdlib.h. It's a standard C function.
    Quzah.
    I could be wrong on this, I thought I saw one of the other Turbo-C users do it this way.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    I could be wrong on this, I thought I saw one of the other Turbo-C users do it this way.
    It wouldn't surprise me.


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    system() is OK to use without including windows.h in Turbo C/C++, *IF* TC/BIN is included in your path= command, in your system.

    If you alt+F, D, you can see what your path is by entering the single word, path, in the DOS (text) window.

    Follow this guide in Windows XP, to change your path variable:
    How to set the path in Windows 2000 / Windows XP.

    Note that getchar() will do the same thing, and is far more preferred.

    I love Turbo C, but it's days in the Sun are long gone. Once your class is over, move over to one of the newer compilers, or you will be left 20+ years behind the times. Time moves on.
    Last edited by Adak; 07-15-2011 at 07:55 PM.

  10. #10
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Including the windows.h header includes quite a few standard headers, stdlib.h is quite possibly in this mix.


    Jim

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    I somehow doubt your school has a contract with Borland for a 20 year old compiler.Quzah.
    LOL... considering Borland hasn't existed in 10 years, I'd say that's a pretty safe bet.
    Last edited by CommonTater; 07-15-2011 at 08:40 PM.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by CommonTater View Post
    LOL... considering Borland hasn't existed in 10 years, I'd say that's a pretty safe bet.
    Thing I don't get is how come there isn't an uprising about outdated courses and incompetent teaching...

    Surely at least some of these students have to realize that going to the job market with skills based on decades old, non-standard, 16 bit compilers is simply going to get them directions to the unemployment office...

  13. #13
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    3 guesses on where the student goes to school.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 06-16-2011, 11:59 AM
  2. first characters in a string
    By starternewb in forum C Programming
    Replies: 3
    Last Post: 03-27-2011, 07:34 AM
  3. Replies: 5
    Last Post: 05-09-2010, 10:58 AM
  4. getting characters from a string that...
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 06-05-2002, 03:13 PM
  5. Concatenating: characters->string->vector (string) :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 02-02-2002, 01:14 PM