well I after talking to someone about having it in a different format I tried:
insert
Code:
int _tmain(int argc, _TCHAR* argv[])
{
void combine(char*new_str1, int n, char c, float f);
char str1[100];
int n;
char c;
float f;
printf("\nEnter an integer:\n");
scanf_s("%d", &n);
printf("\nEnter a character:\n");
scanf_s("%c", &c);
printf("\nEnter a floating point number:\n");
scanf_s("%f", &f);
combine(str1, n,c,f);
puts(str1);
return 0;
}
{
combine(str1, n,c,f,)
{
str1=sprintf_s(str1, "%d, %f, %c", n,c,f);
return (str1);
}
}
but it made me go backwards-it doesn't even run it says missing function header; which i thought is included. But the other way that almost works looks like this:
insert
Code:
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#define max 10
int _tmain(int argc, _TCHAR* argv[])
{
char str1[100];
int n;
char c;
float f;
printf("\nEnter an integer:\n");
scanf_s("%d", &n);
printf("\nEnter a character:\n");
scanf_s("%c", &c);
printf("\nEnter a floating point number:\n");
scanf_s("%f", &f);
sprintf_s(str1, "%d,%c,%f", n,c,f);
puts(str1);
return 0;
}
Also if you have time please look at my linked list: it works fine but I need to adjust it to prompt for another entry, add it to the linked list, and then re-display the new list. thanks for your help
insert
Code:
#include "stdafx.h"
#define maxnum 10
struct value
{
int num[maxnum];
struct value*nextaddr;
};
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,d,e,f;
printf("please enter five numbers:");
scanf("%d,%d,%d,%d,%d", &a,&b,&c,&d,&e,&f);
struct value t1={a};
struct value t2={b};
struct value t3={c};
struct value t4={d};
struct value t5={e};
struct value *first;
void display (struct value*);
first=&t1;
t1.nextaddr=&t2;
t2.nextaddr=&t3;
t3.nextaddr=&t4;
t4.nextaddr=&t5;
t5.nextaddr=NULL;
display (first);
return 0;
}
void display(struct value*contents)
{
while (contents!=NULL)
{
printf("%-10d", *contents->num);
contents=contents->nextaddr;
}