newbie with string question

This is a discussion on newbie with string question within the C Programming forums, part of the General Programming Boards category; I am trying to write a program that accepts input from the keyboard which includes floating poit numbers,character and integers. ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    11

    newbie with string question

    I am trying to write a program that accepts input from the keyboard which includes floating poit numbers,character and integers. The value of each shoykd be stored with variable names and the program will call for function that assembles a string using puts() in main after the function has completed.
    I am getting 3 errors= combine functions does not have 5 parameters and syntax error &, and function header, Please help!!!!

    Code:
    
    
    #include <stdio.h>
    #include <string.h>
    void combine (char c, int num, floatnum);
    int main()
    {
    char strng1[80],strng2[100];
    int num;
    char c;
    floatnum;
    printf("enter a string:");
    gets(strng1);
    printf("enter an integer number:");
    scanf("%d", &num);
    printf("enter a character:");
    scanf("%c", &c);
    printf("enter a floating point:");
    scanf("%f",&floatnum);
    combine (strng1, strng2, &num, floatnum, &c );
    printf("A string containing all inputs is:");
    puts(strng2);
    return 0;
    }
    void combine(char c,char *dest, int num,floatnum)
    {
    sprintf(dest,"%c%d%1f",source, floatnum);
    return 0;
    }

  2. #2
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    void combine (char c, int num, floatnum);

    This declaration is wrong. What you really want is :
    void combine (char c, char* dest, int num, floatnum);

    floatnum;

    What the heck is a floatnum ?

    Fix those problems. Then tell me what's wrong.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I've got a better idea: Stop spamming the forum!


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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-26-2003, 11:03 PM
  4. String array question
    By gogo in forum C++ Programming
    Replies: 6
    Last Post: 12-08-2001, 05:44 PM

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