Like Tree3Likes
  • 1 Post By laserlight
  • 1 Post By Salem
  • 1 Post By Salem

Need a quick check for this function call

This is a discussion on Need a quick check for this function call within the C Programming forums, part of the General Programming Boards category; Ok guys, I'm about to smash my computer. I am doing this function call the same way I have it ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Need a quick check for this function call

    Ok guys, I'm about to smash my computer. I am doing this function call the same way I have it in another program but it keeps tell me that when I try to call the function "a" is not indentified. Am I completly missing something?
    Code:
    #include <stdio.h>
    #include <stdlib.h>
     
    int initialize(int a[]);
    int main()
    {
     const int MAXSIZE = 20;
     int arr[20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
     int selection = 0;
     int choice;
    
     printf("Please select an option\n");
     printf("    0 - initialize\n");
     printf("    1 - square\n");
     printf("    2 - halve\n");
     printf("    3 - accumulate\n");
     printf("    4 - transpose\n");
     printf("    5 - shift\n");
     printf("    6 - reverse\n");
     printf("    or anything other integer to exit\n");
     scanf("%d \n", &selection);
     if(selection == 0);
     {
     choice = initialize(a); //This is where it tell me a is not identified
     }
      
    }
    int initialize(int a[])
    {
     
     
     int a [20] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
     int i = 0;
     
     printf("now the array is \n");
     for(i = 0; i <= 20; i++)
     {
      
      
      printf("%d", a[i]);
     }
     return 0;
    }
    I havent finished the if statement cause that "a not identified" is driving me crazy
    Last edited by phillyflyers; 04-17-2013 at 10:40 PM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    You did not declare a in main.
    phillyflyers likes this.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    41
    my complier must be broken it is still giving me that error, I even went as far as declaring it in the if loop to see if it removed the red underline but nothing.


    ...also its stay my scanf is incorrect when I try to debug now

    1>c:\users\ncc-1701\documents\visual studio 2012\projects\consoleapplication10\consoleapplicat ion10\source.c(26): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    Last edited by phillyflyers; 04-17-2013 at 10:49 PM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    > choice = initialize(a); //This is where it tell me a is not identified
    Because your array is called 'arr', not 'a'

    Line 32 is a waste of space.

    > for(i = 0; i <= 20; i++)
    And this is an array overrun.
    phillyflyers likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    41
    Thank for the help guys, now I just have to figure out why 2012 studio is being crazy and giving me that error

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    Quote Originally Posted by phillyflyers View Post
    1>c:\users\ncc-1701\documents\visual studio 2012\projects\consoleapplication10\consoleapplicat ion10\source.c(26): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    We normally suggest either putting this at the start of the source file.
    Code:
    #define _CRT_SECURE_NO_WARNINGS
    Or putting _CRT_SECURE_NO_WARNINGS in project->settings->compiler->predefined preprocessor symbols.
    phillyflyers likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Feb 2013
    Posts
    41
    thanks you very much I was pullin my hair out over here

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick check
    By SofaWolf in forum C Programming
    Replies: 6
    Last Post: 06-26-2012, 12:53 PM
  2. Need a quick check
    By Aliaks in forum C++ Programming
    Replies: 7
    Last Post: 06-05-2009, 04:57 AM
  3. Quick input check question
    By Jozrael in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2009, 06:23 AM
  4. Quick check on reading in + using strings
    By advancedk in forum C Programming
    Replies: 2
    Last Post: 12-08-2008, 09:12 PM
  5. Need advice: catch exceptions or call methods to check bits?
    By registering in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2003, 01:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21