Thread: Concatenation using system()

  1. #16
    Registered User julianenepom's Avatar
    Join Date
    Sep 2010
    Location
    Portugal or UK
    Posts
    19
    If anyone have any tips, here is the whole code:

    Thanks again! =)

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int main ()
    {
      char var[9] = {0};
      char str[80];
    
      scanf( "%8s", &var );
    
      strcpy (str,"ren C:\\temp\\text.txt text");
      strcat (str, var );
      strcat (str,".txt");
      puts (str);
      system(str);
      system("pause");
      
      return 0;
    }

  2. #17
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You don't need the ampersand, since var is a character array var without the ampersand would be the address of the array.
    Code:
     scanf( "%8s", &var );
    When you are having problems the first thing you should look at is: Are your inputs correct? If you would print out the var variable after the scanf you would probably see a problem.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. concatenation
    By valthyx in forum C Programming
    Replies: 5
    Last Post: 01-17-2010, 08:22 AM
  2. Concatenation ?
    By koolguysj in forum C Programming
    Replies: 8
    Last Post: 04-15-2005, 04:26 PM
  3. concatenation
    By rose2626 in forum C++ Programming
    Replies: 10
    Last Post: 04-25-2003, 01:27 PM
  4. concatenation
    By F*SH in forum C++ Programming
    Replies: 34
    Last Post: 11-13-2002, 06:47 PM
  5. Concatenation in C++
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 12-05-2001, 01:05 PM