LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-31-2003, 12:31 PM   #1
Linh
Member
 
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
function won ' t return character array word


function won ' t return character array word

===========================

root:~# ./test-small-network-sh-4

in read_file_nic word = 0001010002020004110009440005050008220007280010480012330010100013090016440013520032200020550019040019
21
1 in main word = <---- word array is empty

===========================
Code:
#include <stdio.h>         
#include <stdlib.h> 
#include <string.h>

char read_file_nic(word)
  char word[256];
  {
    FILE *interface, *fopen();

    /* process_name_2 is now a file name */
    interface = fopen(process_name_2, "r");
    if (fopen(process_name_2, "r") == NULL)
      {
         perror("Couldn't open file");
         /* shut_down_services(); */
         exit(1);
      }

    fscanf(interface, "%s", word);
    printf("in read_file_nic word = %s\n", word);

    fclose(interface);
    return(word[0]);
  }

/********************************/

main()
 {
   char word [256] = "";

   read_file_nic(process_name_2, word);
   printf ("1 in main word = %s\n", word);

 }

Last edited by Linh; 07-31-2003 at 12:38 PM.
 
Old 07-31-2003, 07:11 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
Re: function won ' t return character array word

Quote:
Originally posted by Linh
Code:
char read_file_nic(word)
  char word[256];
Change it. Give one of 'word's a different name.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pattern file with no return character ksun Linux - Newbie 1 12-28-2004 07:40 PM
How to return values into an array using awk Helene Programming 1 05-01-2004 11:05 PM
Java: Change first character in word to upper AMMullan Programming 4 04-05-2004 04:16 PM
C can 't return a character array Linh Programming 5 06-18-2003 05:58 AM
Cannot pass and return a character array Linh Programming 1 06-12-2003 05:17 PM


All times are GMT -5. The time now is 05:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration